summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2017-03-29 10:15:09 +0300
committerRichard Lowe <richlowe@richlowe.net>2017-03-30 12:07:44 -0400
commita6ab12d6f9f3977ca030fee8770f9fec7ec48bd2 (patch)
treef1c0830ac81447c31666ed8eb0b9bd1cc55e482d
parent56350fe51602d105c19353b8bf580ddd591726d5 (diff)
downloadillumos-joyent-a6ab12d6f9f3977ca030fee8770f9fec7ec48bd2.tar.gz
4678 lms and heci can probably be EOF'd
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r--usr/src/cmd/Makefile1
-rw-r--r--usr/src/cmd/Makefile.check3
-rw-r--r--usr/src/cmd/devfsadm/i386/misc_link_i386.c13
-rw-r--r--usr/src/cmd/lms/Channel.h107
-rw-r--r--usr/src/cmd/lms/ConfigConnection.cpp191
-rw-r--r--usr/src/cmd/lms/ConfigConnection.h80
-rw-r--r--usr/src/cmd/lms/LMEConnection.cpp1049
-rw-r--r--usr/src/cmd/lms/LMEConnection.h412
-rw-r--r--usr/src/cmd/lms/LMEConnectionCompat.cpp335
-rw-r--r--usr/src/cmd/lms/LMS_if.h232
-rw-r--r--usr/src/cmd/lms/LMS_if_compat.h273
-rw-r--r--usr/src/cmd/lms/LMS_if_constants.h114
-rw-r--r--usr/src/cmd/lms/Makefile82
-rw-r--r--usr/src/cmd/lms/PortForwardRequest.h102
-rw-r--r--usr/src/cmd/lms/Protocol.cpp1815
-rw-r--r--usr/src/cmd/lms/Protocol.h191
-rw-r--r--usr/src/cmd/lms/ProtocolCompat.cpp162
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Event.h63
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Lock.h97
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/RWLock.h58
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/SPtr.h196
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Semaphore.h59
-rw-r--r--usr/src/cmd/lms/SyncLib/Include/Thread.h104
-rw-r--r--usr/src/cmd/lms/SyncLib/src/EventUnix.cpp177
-rw-r--r--usr/src/cmd/lms/SyncLib/src/RWLock.cpp95
-rw-r--r--usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp76
-rw-r--r--usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp191
-rw-r--r--usr/src/cmd/lms/THIRDPARTYLICENSE27
-rw-r--r--usr/src/cmd/lms/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/cmd/lms/glue.cpp349
-rw-r--r--usr/src/cmd/lms/glue.h70
-rw-r--r--usr/src/cmd/lms/heci/FWULCommand.cpp233
-rw-r--r--usr/src/cmd/lms/heci/FWULCommand.h147
-rw-r--r--usr/src/cmd/lms/heci/HECIUnix.cpp295
-rw-r--r--usr/src/cmd/lms/heci/HECIUnix.h57
-rw-r--r--usr/src/cmd/lms/heci/HECI_if.h126
-rw-r--r--usr/src/cmd/lms/heci/MNGCommand.cpp147
-rw-r--r--usr/src/cmd/lms/heci/MNGCommand.h78
-rw-r--r--usr/src/cmd/lms/heci/PTHICommand.cpp1236
-rw-r--r--usr/src/cmd/lms/heci/PTHICommand.h770
-rw-r--r--usr/src/cmd/lms/heci/StatusCodeDefinitions.h421
-rw-r--r--usr/src/cmd/lms/heci/heci.h84
-rw-r--r--usr/src/cmd/lms/iatshareddata.h37
-rw-r--r--usr/src/cmd/lms/lms.xml100
-rw-r--r--usr/src/cmd/lms/main.cpp384
-rw-r--r--usr/src/cmd/lms/plugin.h65
-rw-r--r--usr/src/cmd/lms/svc-lms39
-rw-r--r--usr/src/cmd/lms/tools/ATNetworkTool.cpp735
-rw-r--r--usr/src/cmd/lms/tools/ATNetworkTool.h553
-rw-r--r--usr/src/cmd/lms/tools/ATVersion.cpp204
-rw-r--r--usr/src/cmd/lms/tools/ATVersion.h87
-rw-r--r--usr/src/cmd/lms/tools/daemonize.cpp138
-rw-r--r--usr/src/cmd/lms/tools/daemonize.h40
-rw-r--r--usr/src/cmd/lms/types.h168
-rw-r--r--usr/src/cmd/lms/version.h45
-rw-r--r--usr/src/man/man1m/Makefile5
-rw-r--r--usr/src/man/man1m/lms.1m68
-rw-r--r--usr/src/man/man7d/Makefile25
-rw-r--r--usr/src/man/man7d/heci.7d43
-rw-r--r--usr/src/pkg/manifests/system-management-intel-amt.mf52
-rw-r--r--usr/src/uts/intel/Makefile.files9
-rw-r--r--usr/src/uts/intel/Makefile.intel3
-rw-r--r--usr/src/uts/intel/Makefile.rules9
-rw-r--r--usr/src/uts/intel/heci/Makefile82
-rw-r--r--usr/src/uts/intel/io/heci/THIRDPARTYLICENSE39
-rw-r--r--usr/src/uts/intel/io/heci/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/uts/intel/io/heci/heci.h157
-rw-r--r--usr/src/uts/intel/io/heci/heci_data_structures.h607
-rw-r--r--usr/src/uts/intel/io/heci/heci_init.c1203
-rw-r--r--usr/src/uts/intel/io/heci/heci_interface.c562
-rw-r--r--usr/src/uts/intel/io/heci/heci_interface.h165
-rw-r--r--usr/src/uts/intel/io/heci/heci_intr.c1638
-rw-r--r--usr/src/uts/intel/io/heci/heci_main.c1535
-rw-r--r--usr/src/uts/intel/io/heci/io_heci.c904
-rw-r--r--usr/src/uts/intel/io/heci/version.h54
75 files changed, 19 insertions, 20056 deletions
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index 7b538ec1fb..22a031cbdb 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -482,7 +482,6 @@ i386_SUBDIRS= \
addbadsec \
biosdev \
diskscan \
- lms \
rtc \
ucodeadm \
xvm
diff --git a/usr/src/cmd/Makefile.check b/usr/src/cmd/Makefile.check
index fbe01f3b28..2ad038596b 100644
--- a/usr/src/cmd/Makefile.check
+++ b/usr/src/cmd/Makefile.check
@@ -22,7 +22,7 @@
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
include ../Makefile.master
@@ -53,7 +53,6 @@ MANIFEST_TOPDIRS= \
keyserv \
ldapcachemgr \
ldmad \
- lms \
dlmgmtd \
ndmpd \
nscd \
diff --git a/usr/src/cmd/devfsadm/i386/misc_link_i386.c b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
index 84a24b1092..67d06ee101 100644
--- a/usr/src/cmd/devfsadm/i386/misc_link_i386.c
+++ b/usr/src/cmd/devfsadm/i386/misc_link_i386.c
@@ -48,7 +48,6 @@ static int mc_node(di_minor_t minor, di_node_t node);
static int xsvc(di_minor_t minor, di_node_t node);
static int srn(di_minor_t minor, di_node_t node);
static int ucode(di_minor_t minor, di_node_t node);
-static int heci(di_minor_t minor, di_node_t node);
static devfsadm_create_t misc_cbt[] = {
@@ -89,9 +88,6 @@ static devfsadm_create_t misc_cbt[] = {
{ "pseudo", "ddi_pseudo", "ucode",
TYPE_EXACT | DRV_EXACT, ILEVEL_0, ucode,
},
- { "pseudo", "ddi_pseudo", "heci",
- TYPE_EXACT | DRV_EXACT, ILEVEL_0, heci,
- }
};
DEVFSADM_CREATE_INIT_V0(misc_cbt);
@@ -397,12 +393,3 @@ ucode(di_minor_t minor, di_node_t node)
(void) devfsadm_mklink("ucode", node, minor, 0);
return (DEVFSADM_CONTINUE);
}
-
-static int
-heci(di_minor_t minor, di_node_t node)
-{
- if (strcmp(di_minor_name(minor), "AMT") == 0) {
- (void) devfsadm_mklink("heci", node, minor, 0);
- }
- return (DEVFSADM_CONTINUE);
-}
diff --git a/usr/src/cmd/lms/Channel.h b/usr/src/cmd/lms/Channel.h
deleted file mode 100644
index 936db35827..0000000000
--- a/usr/src/cmd/lms/Channel.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _CHANNEL_H_
-#define _CHANNEL_H_
-
-#include "PortForwardRequest.h"
-
-#ifdef _LINUX
-#ifndef SOCKET
-#define SOCKET int
-#endif
-#endif
-
-class Channel
-{
-public:
- enum CHANNEL_STATUS {
- NOT_OPENED,
- OPEN,
- WAITING_CLOSE,
- CLOSED
- };
-
- static const unsigned int LMS_WINDOW_SIZE = 4095;
-
- Channel(PortForwardRequest *portForwardRequest, SOCKET socket) :
- _recipientChannel(0),
- _senderChannel((unsigned int)socket),
- _socket(socket),
- _txWindow(0),
- _rxWindow(LMS_WINDOW_SIZE),
- _status(NOT_OPENED),
- _portForwardRequest(portForwardRequest) {}
-
- unsigned int GetRecipientChannel() const { return _recipientChannel; }
- unsigned int GetSenderChannel() const { return _senderChannel; }
- bool SetRecipientChannel(unsigned int recipientChannel) { _recipientChannel = recipientChannel; return true; }
- unsigned int GetTxWindow() const { return _txWindow; }
- unsigned int GetRxWindow() const { return _rxWindow; }
-
- bool AddBytesTxWindow(const int bytesToAdd)
- {
- if (_txWindow + bytesToAdd < 0) {
- _txWindow = 0;
- return true;
- }
- _txWindow += bytesToAdd;
- return true;
- }
-
- bool AddBytesRxWindow(const int bytesToAdd)
- {
- if (_rxWindow + bytesToAdd < 0) {
- _rxWindow = 0;
- return true;
- }
- _rxWindow = (_rxWindow + bytesToAdd > LMS_WINDOW_SIZE) ?
- (LMS_WINDOW_SIZE) :
- (_rxWindow + bytesToAdd);
- return true;
- }
-
- SOCKET GetSocket() const { return _socket; }
- CHANNEL_STATUS GetStatus() const { return _status; }
- bool SetStatus(const CHANNEL_STATUS newStatus) { _status = newStatus; return true; }
- PortForwardRequest * GetPortForwardRequest() const { return _portForwardRequest; }
-
-
-private:
- unsigned int _recipientChannel;
- const unsigned int _senderChannel;
- const SOCKET _socket;
- unsigned int _txWindow;
- unsigned int _rxWindow;
- CHANNEL_STATUS _status;
- PortForwardRequest *_portForwardRequest;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/ConfigConnection.cpp b/usr/src/cmd/lms/ConfigConnection.cpp
deleted file mode 100644
index c2ff34a593..0000000000
--- a/usr/src/cmd/lms/ConfigConnection.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "ConfigConnection.h"
-#include "Lock.h"
-
-ConfigConnection::ConfigConnection(bool verbose) :
-_initState(ConfigConnection::INIT_STATE_DISCONNECTED),
-_pthiCommand(verbose, 5000),
-_fwulCommand(verbose)
-{
-}
-
-ConfigConnection::~ConfigConnection()
-{
-}
-
-bool ConfigConnection::IsInitialized()
-{
- Lock il(_initLock);
- return ((_initState == INIT_STATE_CONNECTED) ? true : false);
-}
-
-int ConfigConnection::IsAMTEnabled(bool useOpenPTHI)
-{
- FWU_GET_VERSION_MSG_REPLY verMsg;
- FWU_GET_INFO_MSG_REPLY infoMsg;
- HECI_STATUS heciRet;
- int ret = _CFCON_AMT_UNKNOWN;
-
- if (useOpenPTHI) {
- CODE_VERSIONS ver;
- AMT_STATUS ast = _pthiCommand.GetCodeVersions(ver);
- if (PTHI_STATUS_EMPTY_RESPONSE == ast) {
- return _CFCON_AMT_DISABLED;
- }
- if (AMT_STATUS_SUCCESS == ast) {
- return _CFCON_AMT_ENABLED;
- }
- return ret;
- }
-
- if (_fwulCommand.FWULClient.Init()) {
- heciRet = _fwulCommand.GetFWUVersionAndInfo(verMsg, infoMsg);
- _fwulCommand.FWULClient.Deinit();
- if (HECI_STATUS_OK == heciRet) {
- if (infoMsg.MessageType == FWU_GET_INFO_REPLY) {
- return ((MEFWCAPS_MANAGEABILITY_SUPP_AMT
- == infoMsg.ManageabilityMode)
- ? _CFCON_AMT_ENABLED
- : _CFCON_AMT_DISABLED);
- }
- ret = _CFCON_AMT_AT3;
- }
- }
-
- return ret;
-}
-
-bool ConfigConnection::Init(bool checkEnabled)
-{
- {
- Lock il(_initLock);
- if (_initState == INIT_STATE_CONNECTING) {
- return false;
- }
- _initState = INIT_STATE_CONNECTING;
- }
-
- if (!(_pthiCommand.PTHIClient.Init(1))) {
- Deinit();
- return false;
- }
-
- if (checkEnabled) {
- if (_CFCON_AMT_ENABLED != IsAMTEnabled(true)) {
- Deinit();
- return false;
- }
- }
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTING) {
- _pthiCommand.PTHIClient.Deinit();
- return false;
- }
- _initState = INIT_STATE_CONNECTED;
- }
-
- return true;
-}
-
-void ConfigConnection::Deinit()
-{
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTING) {
- _pthiCommand.PTHIClient.Deinit();
- }
- _initState = INIT_STATE_DISCONNECTED;
-}
-
-#ifdef _REMOTE_SUPPORT
-
-AMT_STATUS ConfigConnection::RequestEntDNSSuffixList(std::list<std::string> &dnsSuffixList)
-{
- Lock l(_requestLock);
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTED) {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- }
-
- AMT_STATUS result = _pthiCommand.GetDNSSuffixList(dnsSuffixList);
-
- if (result == AMT_STATUS_INTERNAL_ERROR) {
- Lock il(_initLock);
- if (!_pthiCommand.PTHIClient.IsInitialized()) {
- _initState = INIT_STATE_DISCONNECTED;
- }
- }
-
- return result;
-}
-
-AMT_STATUS ConfigConnection::SendEnterpriseAccess(bool access, ATAddress &localIp)
-{
- UINT8 hlocalIP[16];
- const struct sockaddr *addr = localIp.addr();
-
- Lock l(_requestLock);
-
- {
- Lock il(_initLock);
- if (_initState != INIT_STATE_CONNECTED) {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- }
-
- memset(hlocalIP, 0, sizeof(hlocalIP));
- memcpy(hlocalIP, addr->sa_data, localIp.size());
-
- AMT_STATUS result = _pthiCommand.SetEnterpriseAccess(
- ((localIp.family() == AF_INET6) ? 1 : 0),
- hlocalIP,
- ((access) ? 1 : 0));
-
- if (result == AMT_STATUS_INTERNAL_ERROR) {
- Lock il(_initLock);
- if (!_pthiCommand.PTHIClient.IsInitialized()) {
- _initState = INIT_STATE_DISCONNECTED;
- }
- }
-
- return result;
-}
-
-#endif
-
diff --git a/usr/src/cmd/lms/ConfigConnection.h b/usr/src/cmd/lms/ConfigConnection.h
deleted file mode 100644
index a6c31686ab..0000000000
--- a/usr/src/cmd/lms/ConfigConnection.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __CONFIG_CONNECTION_H__
-#define __CONFIG_CONNECTION_H__
-
-#include <list>
-#include <string>
-#include "Semaphore.h"
-#include "PTHICommand.h"
-#include "FWULCommand.h"
-#ifdef _REMOTE_SUPPORT
-#include "ATNetworkTool.h"
-#endif
-
-#define _CFCON_AMT_DISABLED 0
-#define _CFCON_AMT_ENABLED 1
-#define _CFCON_AMT_UNKNOWN 2
-#define _CFCON_AMT_AT3 3
-
-class ConfigConnection
-{
-public:
- ConfigConnection(bool verbose = false);
- ~ConfigConnection();
-
- bool Init(bool checkEnabled = true);
- bool IsInitialized();
- void Deinit();
- int IsAMTEnabled(bool useOpenPTHI = false);
-
-#ifdef _REMOTE_SUPPORT
- AMT_STATUS RequestEntDNSSuffixList(std::list<std::string> &dnsSuffixList);
- AMT_STATUS SendEnterpriseAccess(bool access, ATAddress &localIp);
-#endif
-
- enum INIT_STATES {
- INIT_STATE_DISCONNECTED = 0,
- INIT_STATE_CONNECTING,
- INIT_STATE_CONNECTED
- };
-
-private:
- Semaphore _initLock;
- Semaphore _requestLock;
- INIT_STATES _initState;
-
- PTHICommand _pthiCommand;
- FWULCommand _fwulCommand;
-};
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMEConnection.cpp b/usr/src/cmd/lms/LMEConnection.cpp
deleted file mode 100644
index e0a669de8e..0000000000
--- a/usr/src/cmd/lms/LMEConnection.cpp
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cerrno>
-#include "types.h"
-#include "LMEConnection.h"
-#include "LMS_if.h"
-#include "Lock.h"
-#include "glue.h"
-
-#if defined(__sun) || defined(_LINUX)
-#include <netinet/in.h>
-#define _strnicmp strncasecmp
-#endif // __sun || _LINUX
-
-#define HECI_IO_TIMEOUT 5000
-
-extern glue plugin;
-
-const GUID LMEConnection::_guid = {0x6733a4db, 0x0476, 0x4e7b, {0xb3, 0xaf, 0xbc, 0xfc, 0x29, 0xbe, 0xe7, 0xa7}};
-
-const UINT32 LMEConnection::RX_WINDOW_SIZE = 1024;
-
-LMEConnection::LMEConnection(bool verbose) :
-_reqID(0),
-_txBuffer(NULL),
-_rxThread(NULL),
-_cb(NULL),
-_cbParam(NULL),
-_initState(INIT_STATE_DISCONNECTED),
-_heci(_guid, verbose),
-_heciCompat(_guidCompat, verbose),
-_pHeci(NULL)
-{
-}
-
-LMEConnection::~LMEConnection()
-{
-}
-
-bool LMEConnection::IsInitialized()
-{
- Lock il(_initLock);
- return ((_initState == INIT_STATE_CONNECTED) ? true : false);
-}
-
-bool LMEConnection::Init(HECICallback cb, void *param)
-{
- Lock il(_initLock);
-
- if (_initState == INIT_STATE_CONNECTING) {
- return false;
- }
- _initState = INIT_STATE_CONNECTING;
-
- _cb = cb;
- _cbParam = param;
-
- if (_heci.Init(LMS_PROCOL_VERSION)) {
- protocolVer = _heci.GetProtocolVersion();
- _pHeci = &_heci;
- } else if (_heciCompat.Init()) {
- protocolVer = _heciCompat.GetProtocolVersion();
- if (protocolVer > LMS_PROCOL_VERSION_COMPAT) {
- _heciCompat.Deinit();
- _initState = INIT_STATE_DISCONNECTED;
- return false;
- }
- _pHeci = &_heciCompat;
- } else {
- _initState = INIT_STATE_DISCONNECTED;
- return false;
- }
-
- _initState = INIT_STATE_CONNECTED;
-
- plugin.version(protocolVer);
-
- // launch RX thread
- _txBuffer = new unsigned char[_pHeci->GetBufferSize()];
- _rxThread = new Thread(_rxThreadFunc, this);
- _rxThread->start();
-
- _threadStartedEvent.wait();
- return true;
-}
-
-void LMEConnection::Deinit()
-{
- Lock il(_initLock);
-
- _initState = INIT_STATE_DISCONNECTED;
-
- if (_pHeci != NULL) {
- _pHeci->Deinit();
- _pHeci = NULL;
- }
-
- if (_rxThread != NULL) {
- delete _rxThread;
- _rxThread = NULL;
- }
-
- if (_txBuffer != NULL) {
- delete[] _txBuffer;
- _txBuffer = NULL;
- }
-}
-
-bool LMEConnection::Disconnect(APF_DISCONNECT_REASON_CODE reasonCode)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf[sizeof(APF_DISCONNECT_MESSAGE)];
-
- APF_DISCONNECT_MESSAGE *disconnectMessage = (APF_DISCONNECT_MESSAGE *)buf;
-
- memset(disconnectMessage, 0, sizeof(buf));
- disconnectMessage->MessageType = APF_DISCONNECT;
- disconnectMessage->ReasonCode = htonl(reasonCode);
-
- PRINT("Sending disconnect to LME.\n");
- int res = _sendMessage(buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ServiceAccept(std::string serviceName)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- //APF_SERVICE_ACCEPT_MESSAGE
- //memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
- //pCurrent += APF_STR_SIZE_OF("127.0.0.1");
- unsigned char *buf = new unsigned char[sizeof(APF_SERVICE_ACCEPT_MESSAGE) + serviceName.length()];
- if (buf == NULL) {
- PRINT("Failed to allocate memory for ServiceAccept.\n");
- return false;
- }
-
- unsigned char *pCurrent = buf;
- *pCurrent = APF_SERVICE_ACCEPT;
- ++pCurrent;
- *((UINT32 *)pCurrent) = htonl(serviceName.size());
- pCurrent += 4;
-
- memcpy(pCurrent, serviceName.c_str(), serviceName.size());
- pCurrent += serviceName.size();
-
- PRINT("Sending service accept to LME: %s\n", serviceName.c_str());
- int len = pCurrent - buf;
- int res = _sendMessage(buf, len);
-
- delete [] buf;
-
- return (res == len);
-}
-
-bool LMEConnection::UserAuthSuccess()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_USERAUTH_SUCCESS;
-
- PRINT("Sending user authentication success to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ProtocolVersion(const LMEProtocolVersionMessage versionMessage)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_PROTOCOL_VERSION_MESSAGE protVersion;
- memset(&protVersion, 0, sizeof(protVersion));
-
- protVersion.MessageType = APF_PROTOCOLVERSION;
- protVersion.MajorVersion = htonl(versionMessage.MajorVersion);
- protVersion.MinorVersion = htonl(versionMessage.MinorVersion);
- protVersion.TriggerReason = htonl(versionMessage.TriggerReason);
-
- PRINT("Sending protocol version to LME: %d.%d\n", versionMessage.MajorVersion, versionMessage.MinorVersion);
- int res = _sendMessage((unsigned char *)&protVersion, sizeof(protVersion));
-
- return (res == sizeof(protVersion));
-}
-
-bool LMEConnection::TcpForwardReplySuccess(UINT32 port)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_TCP_FORWARD_REPLY_MESSAGE message;
-
- message.MessageType = APF_REQUEST_SUCCESS;
- message.PortBound = htonl(port);
-
- PRINT("Sending TCP forward replay success to LME: Port %d.\n", port);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::TcpForwardReplyFailure()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_FAILURE;
-
- PRINT("Sending TCP forward replay failure to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::TcpForwardCancelReplySuccess()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_SUCCESS;
-
- PRINT("Sending TCP forward cancel replay success to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::TcpForwardCancelReplyFailure()
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf = APF_REQUEST_FAILURE;
-
- PRINT("Sending TCP forward cancel replay failure to LME.\n");
- int res = _sendMessage(&buf, sizeof(buf));
-
- return (res == sizeof(buf));
-}
-
-bool LMEConnection::ChannelOpenForwardedRequest(UINT32 senderChannel,
- UINT32 connectedPort,
- std::string originatorIP,
- UINT32 originatorPort)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char buf[5 + APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED) + 16 +
- APF_STR_SIZE_OF("127.0.0.1") + 8 + 16 + 4];
- unsigned char *pCurrent = buf;
-
- if (originatorIP.size() > 16) {
- return false;
- }
-
- *pCurrent = APF_CHANNEL_OPEN;
- ++pCurrent;
-
- *((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, APF_OPEN_CHANNEL_REQUEST_FORWARDED, APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED));
- pCurrent += APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_FORWARDED);
-
- *((UINT32 *)pCurrent) = htonl(senderChannel);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl(RX_WINDOW_SIZE);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = 0xFFFFFFFF;
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl(APF_STR_SIZE_OF("127.0.0.1"));
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, "127.0.0.1", APF_STR_SIZE_OF("127.0.0.1"));
- pCurrent += APF_STR_SIZE_OF("127.0.0.1");
-
- *((UINT32 *)pCurrent) = htonl(connectedPort);
- pCurrent += sizeof(UINT32);
-
- *((UINT32 *)pCurrent) = htonl((UINT32)originatorIP.size());
- pCurrent += sizeof(UINT32);
-
- memcpy(pCurrent, originatorIP.c_str(), originatorIP.size());
- pCurrent += originatorIP.size();
-
- *((UINT32 *)pCurrent) = htonl(originatorPort);
- pCurrent += sizeof(UINT32);
-
- PRINT("Sending channel open request to LME. Address: %s, requested port: %d.\n",
- originatorIP.c_str(), connectedPort);
- int res = _sendMessage(buf, (int)(pCurrent - buf));
-
- return (res == pCurrent - buf);
-}
-
-bool LMEConnection::ChannelOpenReplaySuccess(UINT32 recipientChannel,
- UINT32 senderChannel)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_OPEN_CONFIRMATION;
- message.RecipientChannel = htonl(recipientChannel);
- message.SenderChannel = htonl(senderChannel);
- message.InitialWindowSize = htonl(RX_WINDOW_SIZE);
- message.Reserved = 0xFFFFFFFF;
-
- PRINT("Sending channel open replay success to LME. Recipient: %d.\n", recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::ChannelOpenReplayFailure(UINT32 recipientChannel,
- UINT32 reason)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_OPEN_FAILURE_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_OPEN_FAILURE;
- message.RecipientChannel = htonl(recipientChannel);
- message.ReasonCode = htonl(reason);
- message.Reserved = 0x00000000;
- message.Reserved2 = 0x00000000;
-
- PRINT("Sending channel open replay failure to LME. Recipient: %d, Reason: %d.\n", recipientChannel, reason);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-bool LMEConnection::ChannelClose(UINT32 recipientChannel)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_CLOSE_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_CLOSE;
- message.RecipientChannel = htonl(recipientChannel);
-
- PRINT("Sending channel close to LME. Recipient: %d.\n", recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-int LMEConnection::ChannelData(UINT32 recipientChannel,
- UINT32 len, unsigned char *buffer)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_CHANNEL_DATA_MESSAGE *message;
-
- if (len > _heci.GetBufferSize() - sizeof(APF_CHANNEL_DATA_MESSAGE)) {
- return -1;
- }
-
- message = (APF_CHANNEL_DATA_MESSAGE *)_txBuffer;
- message->MessageType = APF_CHANNEL_DATA;
- message->RecipientChannel = htonl(recipientChannel);
- message->DataLength = htonl(len);
- memcpy(message->Data, buffer, len);
-
- PRINT("Sending %d bytes to recipient channel %d.\n", len, recipientChannel);
- return _sendMessage((unsigned char *)message, sizeof(APF_CHANNEL_DATA_MESSAGE) + len);
-}
-
-bool LMEConnection::ChannelWindowAdjust(UINT32 recipientChannel, UINT32 len)
-{
- if (!IsInitialized()) {
- PRINT("State: not connected to HECI.\n");
- return false;
- }
-
- APF_WINDOW_ADJUST_MESSAGE message;
-
- message.MessageType = APF_CHANNEL_WINDOW_ADJUST;
- message.RecipientChannel = htonl(recipientChannel);
- message.BytesToAdd = htonl(len);
-
- PRINT("Sending Window Adjust with %d bytes to recipient channel %d.\n", len, recipientChannel);
- int res = _sendMessage((unsigned char *)&message, sizeof(message));
-
- return (res == sizeof(message));
-}
-
-int LMEConnection::_receiveMessage(unsigned char *buffer, int len)
-{
- int result;
-
- if (!IsInitialized()) {
- return -1;
- }
-
- result = _pHeci->ReceiveMessage(buffer, len, WAIT_INFINITE);
-
- if (result < 0 && errno == ENOENT) {
- Lock il(_initLock);
- _initState = INIT_STATE_DISCONNECTED;
- }
-
- return result;
-}
-
-int LMEConnection::_sendMessage(unsigned char *buffer, int len)
-{
- int result;
-
- if (!IsInitialized()) {
- return -1;
- }
-
- _sendMessageLock.acquire();
- result = _pHeci->SendMessage(buffer, len, HECI_IO_TIMEOUT);
- _sendMessageLock.release();
-
- if (result < 0 && errno == ENOENT) {
- Lock il(_initLock);
- _initState = INIT_STATE_DISCONNECTED;
- }
-
- return result;
-}
-
-void LMEConnection::_rxThreadFunc(void *param)
-{
- LMEConnection *connection = (LMEConnection *)param;
-
- try {
- if (LMS_PROCOL_VERSION == connection->protocolVer) {
- connection->_doRX();
- } else if (LMS_PROCOL_VERSION_COMPAT == connection->protocolVer) {
- connection->_doRXCompat();
- }
- }
- catch (...) {
- PRINT("LMEConnection do RX exception\n");
- }
- pthread_exit(NULL);
-}
-
-bool LMEConnection::_checkMinMsgSize(unsigned char *buf, unsigned int bytesRead)
-{
- switch (buf[0]) {
- case APF_DISCONNECT:
- if (bytesRead < sizeof(APF_DISCONNECT_MESSAGE)) {
- return false;
- }
- break;
- case APF_SERVICE_REQUEST:
- if (bytesRead < sizeof(APF_SERVICE_REQUEST)) {
- return false;
- }
- if (bytesRead < (sizeof(APF_SERVICE_REQUEST) +
- ntohl(((APF_SERVICE_REQUEST_MESSAGE *)buf)->ServiceNameLength))) {
- return false;
- }
- break;
- case APF_USERAUTH_REQUEST:
- if (bytesRead < (3 * sizeof(UINT32))) {
- return false;
- }
- break;
- case APF_GLOBAL_REQUEST:
- if (bytesRead < (sizeof(APF_GENERIC_HEADER) + sizeof(UINT8))) {
- return false;
- }
- if (bytesRead < (sizeof(APF_GENERIC_HEADER) + sizeof(UINT8) +
- ntohl(((APF_GENERIC_HEADER *)buf)->StringLength))) {
- return false;
- }
- break;
- case APF_CHANNEL_OPEN:
- if (bytesRead < sizeof(APF_GENERIC_HEADER)) {
- return false;
- }
- if (bytesRead < (sizeof(APF_GENERIC_HEADER) +
- ntohl(((APF_GENERIC_HEADER *)buf)->StringLength))) {
- return false;
- }
- break;
- case APF_CHANNEL_OPEN_CONFIRMATION:
- if (bytesRead < sizeof(APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE)) {
- return false;
- }
- break;
- case APF_CHANNEL_OPEN_FAILURE:
- if (bytesRead < sizeof(APF_CHANNEL_OPEN_FAILURE_MESSAGE)) {
- return false;
- }
- break;
- case APF_CHANNEL_CLOSE:
- if (bytesRead < sizeof(APF_CHANNEL_CLOSE_MESSAGE)) {
- return false;
- }
- break;
- case APF_CHANNEL_DATA:
- if (bytesRead < sizeof(APF_CHANNEL_DATA_MESSAGE)) {
- return false;
- }
- if (bytesRead < (sizeof(APF_CHANNEL_DATA_MESSAGE) +
- ntohl(((APF_CHANNEL_DATA_MESSAGE *)buf)->DataLength))) {
- return false;
- }
- break;
- case APF_CHANNEL_WINDOW_ADJUST:
- if (bytesRead < sizeof(APF_WINDOW_ADJUST_MESSAGE)) {
- return false;
- }
- break;
- case APF_PROTOCOLVERSION:
- if (bytesRead < sizeof(APF_PROTOCOL_VERSION_MESSAGE)) {
- return false;
- }
- break;
- default:
- return false;
- }
- return true;
-}
-
-void LMEConnection::_doRX()
-{
- unsigned int bytesRead;
- int status = 1;
-
- _threadStartedEvent.set();
-
- unsigned char *rxBuffer = new unsigned char[_heci.GetBufferSize()];
-
- while (true) {
- bytesRead = (unsigned int)_receiveMessage(rxBuffer, _heci.GetBufferSize());
-
- if ((int)bytesRead < 0) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (bytesRead == 0) {
- // ERROR
- continue;
- }
-
- PRINT("Received from LME %d bytes (msg type %02d)\n", bytesRead, rxBuffer[0]);
-
- if (!_checkMinMsgSize(rxBuffer, bytesRead)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (plugin.preprocess(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- }
-
- switch (rxBuffer[0]) {
- case APF_DISCONNECT:
- {
- LMEDisconnectMessage disconnectMessage(
- (APF_DISCONNECT_REASON_CODE)ntohl(
- ((APF_DISCONNECT_MESSAGE *)rxBuffer)->ReasonCode));
-
- _cb(_cbParam, &disconnectMessage, sizeof(disconnectMessage), &status);
- }
- break;
-
- case APF_SERVICE_REQUEST:
- {
- APF_SERVICE_REQUEST_MESSAGE *pMessage =
- (APF_SERVICE_REQUEST_MESSAGE *)rxBuffer;
- LMEServiceRequestMessage serviceRequestMessage;
-
- serviceRequestMessage.ServiceName.append(
- (char *)(pMessage->ServiceName),
- ntohl(pMessage->ServiceNameLength));
-
- _cb(_cbParam, &serviceRequestMessage, sizeof(serviceRequestMessage), &status);
- }
- break;
-
- case APF_USERAUTH_REQUEST:
- _apfUserAuthRequest(rxBuffer, bytesRead, &status);
- break;
-
- case APF_GLOBAL_REQUEST:
- _apfGlobalRequest(rxBuffer, bytesRead, &status);
- break;
-
- case APF_CHANNEL_OPEN:
- _apfChannelOpen(rxBuffer, bytesRead, &status);
- break;
-
- case APF_CHANNEL_OPEN_CONFIRMATION:
- {
- APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE *pMessage =
- (APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE *)rxBuffer;
- LMEChannelOpenReplaySuccessMessage channelOpenReply;
-
- channelOpenReply.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelOpenReply.SenderChannel = ntohl(pMessage->SenderChannel);
- channelOpenReply.InitialWindow = ntohl(pMessage->InitialWindowSize);
- _cb(_cbParam, &channelOpenReply, sizeof(channelOpenReply), &status);
- }
- break;
-
- case APF_CHANNEL_OPEN_FAILURE:
- {
- APF_CHANNEL_OPEN_FAILURE_MESSAGE *pMessage =
- (APF_CHANNEL_OPEN_FAILURE_MESSAGE *)rxBuffer;
- LMEChannelOpenReplayFailureMessage channelOpenReply;
-
- channelOpenReply.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelOpenReply.ReasonCode =
- (OPEN_FAILURE_REASON)(ntohl(pMessage->ReasonCode));
- _cb(_cbParam, &channelOpenReply, sizeof(channelOpenReply), &status);
- }
- break;
-
- case APF_CHANNEL_CLOSE:
- {
- APF_CHANNEL_CLOSE_MESSAGE *pMessage =
- (APF_CHANNEL_CLOSE_MESSAGE *)rxBuffer;
- LMEChannelCloseMessage channelClose;
-
- channelClose.RecipientChannel = ntohl(pMessage->RecipientChannel);
- _cb(_cbParam, &channelClose, sizeof(channelClose), &status);
- }
- break;
-
- case APF_CHANNEL_DATA:
- {
- APF_CHANNEL_DATA_MESSAGE *pMessage =
- (APF_CHANNEL_DATA_MESSAGE *)rxBuffer;
- LMEChannelDataMessage channelData(ntohl(pMessage->RecipientChannel),
- ntohl(pMessage->DataLength),
- pMessage->Data);
- _cb(_cbParam, &channelData, sizeof(channelData), &status);
- }
- break;
-
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- APF_WINDOW_ADJUST_MESSAGE *pMessage =
- (APF_WINDOW_ADJUST_MESSAGE *)rxBuffer;
- LMEChannelWindowAdjustMessage channelWindowAdjust;
-
- channelWindowAdjust.RecipientChannel = ntohl(pMessage->RecipientChannel);
- channelWindowAdjust.BytesToAdd = ntohl(pMessage->BytesToAdd);
- _cb(_cbParam, &channelWindowAdjust, sizeof(channelWindowAdjust), &status);
- }
- break;
-
- case APF_PROTOCOLVERSION:
- {
- APF_PROTOCOL_VERSION_MESSAGE *pMessage =
- (APF_PROTOCOL_VERSION_MESSAGE *)rxBuffer;
- LMEProtocolVersionMessage protVersion;
-
- protVersion.MajorVersion = ntohl(pMessage->MajorVersion);
- protVersion.MinorVersion = ntohl(pMessage->MinorVersion);
- protVersion.TriggerReason =
- (APF_TRIGGER_REASON)ntohl(pMessage->TriggerReason);
- _cb(_cbParam, &protVersion, sizeof(protVersion), &status);
- }
- break;
-
- default:
- // Uknown request. Ignore
- break;
- }
-
- if (IsInitialized()) {
- plugin.postprocess(rxBuffer, bytesRead, status);
- }
- }
-
- if (rxBuffer != NULL) {
- delete[] rxBuffer;
- }
-}
-
-void LMEConnection::_apfChannelOpen(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
-{
- APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
-
- if (_strnicmp((char *)pHeader->String,
- APF_OPEN_CHANNEL_REQUEST_DIRECT,
- APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_DIRECT)) == 0) {
-
- UINT32 senderChannel = 0;
-
- _apfChannelOpenDirect(rxBuffer, bytesRead, &senderChannel, status);
- if (IsInitialized() && (*status == 1)) {
- if (plugin.retry(rxBuffer, bytesRead) != LMS_DROPPED) {
- _apfChannelOpenDirect(rxBuffer, bytesRead, NULL, status);
- }
- }
- if (IsInitialized() && (*status == 1)) {
- ChannelOpenReplayFailure(senderChannel,
- OPEN_FAILURE_REASON_CONNECT_FAILED);
- }
- }
-}
-
-void LMEConnection::_apfChannelOpenDirect(unsigned char *rxBuffer, unsigned int bytesRead, UINT32 *senderChannel, int *status)
-{
- unsigned char *pCurrent;
- APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
-
- if (bytesRead < sizeof(APF_GENERIC_HEADER) +
- ntohl(pHeader->StringLength) +
- 7 + (5 * sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- pCurrent = rxBuffer + sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_OPEN_CHANNEL_REQUEST_DIRECT);
-
- LMEChannelOpenRequestMessage channelOpenRequest;
- channelOpenRequest.ChannelType = LMEChannelOpenRequestMessage::DIRECT;
-
- channelOpenRequest.SenderChannel = ntohl(*((UINT32 *)pCurrent));
- if (senderChannel) {
- *senderChannel = channelOpenRequest.SenderChannel;
- }
- pCurrent += sizeof(UINT32);
- channelOpenRequest.InitialWindow = ntohl(*((UINT32 *)pCurrent));
- pCurrent += 2 * sizeof(UINT32);
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
- channelOpenRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- channelOpenRequest.Port = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- _cb(_cbParam, &channelOpenRequest, sizeof(channelOpenRequest), status);
-}
-
-void LMEConnection::_apfGlobalRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
-{
- unsigned char *pCurrent;
- APF_GENERIC_HEADER *pHeader = (APF_GENERIC_HEADER *)rxBuffer;
-
- if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST)) == 0) {
- LMETcpForwardRequestMessage tcpForwardRequest;
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- tcpForwardRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- tcpForwardRequest.Port = ntohl(*((UINT32 *)pCurrent));
-
- _cb(_cbParam, &tcpForwardRequest, sizeof(tcpForwardRequest), status);
- }
- else if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST)) == 0) {
- LMETcpForwardCancelRequestMessage tcpForwardCancelRequest;
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- tcpForwardCancelRequest.Address.append((char *)pCurrent, len);
- pCurrent += len;
- tcpForwardCancelRequest.Port = ntohl(*((UINT32 *)pCurrent));
-
- _cb(_cbParam, &tcpForwardCancelRequest, sizeof(tcpForwardCancelRequest), status);
- }
- else if (_strnicmp((char *)pHeader->String,
- APF_GLOBAL_REQUEST_STR_UDP_SEND_TO,
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_UDP_SEND_TO)) == 0) {
- unsigned int hsize = sizeof(APF_GENERIC_HEADER) +
- APF_STR_SIZE_OF(APF_GLOBAL_REQUEST_STR_UDP_SEND_TO) +
- sizeof(UINT8);
- pCurrent = rxBuffer + hsize;
- bytesRead -= hsize;
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
- bytesRead -= (sizeof(UINT32) + len + sizeof(UINT32));
-
- std::string address;
- address.append((char *)pCurrent, len);
- pCurrent += len;
- UINT32 port = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- // Skip Originator IP and Port
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len + sizeof(UINT32))) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
- bytesRead -= (sizeof(UINT32) + len + sizeof(UINT32));
-
- pCurrent += len;
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- // Retrieve Data
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if (bytesRead < (sizeof(UINT32) + len)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- LMEUdpSendToMessage udpSendTo(address, port, len, pCurrent);
-
- _cb(_cbParam, &udpSendTo, sizeof(udpSendTo), status);
- }
-}
-
-void LMEConnection::_apfUserAuthRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status)
-{
- unsigned char *pCurrent = rxBuffer;
-
- ++pCurrent;
-
- LMEUserAuthRequestMessage userAuthRequest;
-
- UINT32 len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- userAuthRequest.Username.append((char *)pCurrent, len);
- pCurrent += len;
-
- if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- userAuthRequest.ServiceName.append((char *)pCurrent, len);
- pCurrent += len;
-
- if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(UINT32)) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- userAuthRequest.MethodName.append((char *)pCurrent, len);
- pCurrent += len;
-
- if (_strnicmp(userAuthRequest.MethodName.c_str(), APF_AUTH_PASSWORD,
- userAuthRequest.MethodName.size()) == 0) {
-
- if ((unsigned int)(bytesRead - (pCurrent - rxBuffer)) < sizeof(UINT32) + 1) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- ++pCurrent;
-
- len = ntohl(*((UINT32 *)pCurrent));
- pCurrent += sizeof(UINT32);
-
- if ((bytesRead - (pCurrent - rxBuffer)) < len) {
- PRINT("Error receiving data from HECI\n");
- Deinit();
- return;
- }
-
- AuthPasswordData authData;
- authData.Password.append((char *)pCurrent, len);
- pCurrent += len;
-
- userAuthRequest.MethodData = &authData;
- }
-
- _cb(_cbParam, &userAuthRequest, sizeof(userAuthRequest), status);
-}
-
-unsigned int LMEConnection::GetHeciBufferSize() const
-{
- if (_pHeci == NULL) {
- return 0;
- }
- return _pHeci->GetBufferSize();
-}
-
diff --git a/usr/src/cmd/lms/LMEConnection.h b/usr/src/cmd/lms/LMEConnection.h
deleted file mode 100644
index c71bc3a8d6..0000000000
--- a/usr/src/cmd/lms/LMEConnection.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __LME_CONNECTION_H__
-#define __LME_CONNECTION_H__
-
-#if defined(__sun) || defined(_LINUX)
-#include "HECIUnix.h"
-#else
-#include "HECIWin.h"
-#endif
-
-#include <map>
-#include <string>
-#include "LMS_if.h"
-#include "Thread.h"
-#include "Semaphore.h"
-#include "Event.h"
-#include "ATNetworkTool.h"
-
-
-struct AuthMethodData {
-};
-
-struct AuthPasswordData : AuthMethodData {
- std::string Password;
-};
-
-struct LMEMessage {
-
- LMEMessage(APF_MESSAGE_TYPE type) :
- MessageType(type) {}
-
- const APF_MESSAGE_TYPE MessageType;
-};
-
-struct LMEDisconnectMessage : LMEMessage {
-
- LMEDisconnectMessage(APF_DISCONNECT_REASON_CODE reasonCode) :
- LMEMessage(APF_DISCONNECT),
- ReasonCode(reasonCode) {}
-
- APF_DISCONNECT_REASON_CODE ReasonCode;
-};
-
-struct LMEServiceRequestMessage : LMEMessage {
-
- LMEServiceRequestMessage(std::string serviceName = "") :
- LMEMessage(APF_SERVICE_REQUEST),
- ServiceName(serviceName) {}
-
- std::string ServiceName;
-};
-
-struct LMEGlobalRequestMessage : LMEMessage {
-
- enum REQUEST_TYPE {
- TCP_FORWARD_REQUEST,
- TCP_FORWARD_CANCEL_REQUEST,
- UDP_SEND_TO
- };
-
- LMEGlobalRequestMessage(REQUEST_TYPE type) :
- LMEMessage(APF_GLOBAL_REQUEST),
- RequestType(type) {}
-
- const REQUEST_TYPE RequestType;
-};
-
-struct LMEProtocolVersionMessage : LMEMessage {
-
- LMEProtocolVersionMessage(UINT32 majorVersion = 0,
- UINT32 minorVersion = 0,
- APF_TRIGGER_REASON triggerReason = LME_REQUEST) :
- LMEMessage(APF_PROTOCOLVERSION),
- MajorVersion(majorVersion),
- MinorVersion(minorVersion),
- TriggerReason(triggerReason) {}
-
- UINT32 MajorVersion;
- UINT32 MinorVersion;
- APF_TRIGGER_REASON TriggerReason;
-
- struct LMEProtocolVersionMessage &operator=(const struct LMEProtocolVersionMessage &y)
- {
- if (this != &y) {
- this->MajorVersion = y.MajorVersion;
- this->MinorVersion = y.MinorVersion;
- }
- return *this;
- };
- bool operator<(const struct LMEProtocolVersionMessage &y) const
- {
- if (this->MajorVersion != y.MajorVersion) {
- return (this->MajorVersion < y.MajorVersion);
- }
- return (this->MinorVersion < y.MinorVersion);
- }
- bool operator>(const struct LMEProtocolVersionMessage &y) const
- {
- if (this->MajorVersion != y.MajorVersion) {
- return (this->MajorVersion > y.MajorVersion);
- }
- return (this->MinorVersion > y.MinorVersion);
- }
-};
-
-struct LMEUserAuthRequestMessage : LMEMessage {
-
- LMEUserAuthRequestMessage(std::string username = "",
- std::string serviceName = "",
- std::string methodName = "",
- AuthMethodData *methodData = NULL) :
- LMEMessage(APF_USERAUTH_REQUEST),
- Username(username),
- ServiceName(ServiceName),
- MethodName(methodName),
- MethodData(methodData) {}
-
- std::string Username;
- std::string ServiceName;
- std::string MethodName;
-
- AuthMethodData *MethodData;
-};
-
-
-struct LMETcpForwardRequestMessage : LMEGlobalRequestMessage {
-
- LMETcpForwardRequestMessage(std::string address = "", UINT32 port = 0) :
- LMEGlobalRequestMessage(TCP_FORWARD_REQUEST),
- Address(address),
- Port(port) {}
-
- std::string Address;
- UINT32 Port;
-};
-
-struct LMETcpForwardCancelRequestMessage : LMEGlobalRequestMessage {
-
- LMETcpForwardCancelRequestMessage(std::string address = "", UINT32 port = 0) :
- LMEGlobalRequestMessage(TCP_FORWARD_CANCEL_REQUEST),
- Address(address),
- Port(port) {}
-
- std::string Address;
- UINT32 Port;
-};
-
-struct LMEUdpSendToMessage : LMEGlobalRequestMessage {
-
- LMEUdpSendToMessage(std::string address = "", UINT32 port = 0,
- UINT32 dataLength = 0, UINT8 *data = NULL) :
- LMEGlobalRequestMessage(UDP_SEND_TO),
- Address(address),
- Port(port),
- DataLength(dataLength)
- {
- if ((data != NULL) && (dataLength != 0)) {
- Data = new UINT8[dataLength];
- memcpy(Data, data, dataLength);
- } else {
- Data = NULL;
- }
-
- }
-
- ~LMEUdpSendToMessage()
- {
- if (Data != NULL) {
- delete[] Data;
- Data = NULL;
- }
- }
-
- std::string Address;
- UINT32 Port;
- UINT32 DataLength;
- UINT8 *Data;
-};
-
-struct LMEChannelOpenRequestMessage : LMEMessage {
-
- enum CHANNEL_TYPE {
- FORWARDED,
- DIRECT
- };
-
- LMEChannelOpenRequestMessage(CHANNEL_TYPE channelType = FORWARDED,
- UINT32 senderChannel = 0,
- UINT32 initialWindow = 0,
- std::string address = "", UINT32 port = 0) :
- LMEMessage(APF_CHANNEL_OPEN),
- ChannelType(channelType),
- SenderChannel(senderChannel),
- InitialWindow(initialWindow),
- Address(address),
- Port(port) {}
-
- CHANNEL_TYPE ChannelType;
- UINT32 SenderChannel;
- UINT32 InitialWindow;
- std::string Address;
- UINT32 Port;
-};
-
-struct LMEChannelOpenReplaySuccessMessage : LMEMessage {
-
- LMEChannelOpenReplaySuccessMessage(UINT32 recipientChannel = 0,
- UINT32 senderChannel = 0,
- UINT32 initialWindow = 0) :
- LMEMessage(APF_CHANNEL_OPEN_CONFIRMATION),
- RecipientChannel(recipientChannel),
- SenderChannel(senderChannel),
- InitialWindow(initialWindow) {}
-
- UINT32 RecipientChannel;
- UINT32 SenderChannel;
- UINT32 InitialWindow;
-};
-
-struct LMEChannelOpenReplayFailureMessage : LMEMessage {
-
- LMEChannelOpenReplayFailureMessage(UINT32 recipientChannel = 0,
- OPEN_FAILURE_REASON reasonCode = OPEN_FAILURE_REASON_ADMINISTRATIVELY_PROHIBITED) :
- LMEMessage(APF_CHANNEL_OPEN_FAILURE),
- RecipientChannel(recipientChannel),
- ReasonCode(reasonCode) {}
-
- UINT32 RecipientChannel;
- OPEN_FAILURE_REASON ReasonCode;
-};
-
-struct LMEChannelCloseMessage : LMEMessage {
-
- LMEChannelCloseMessage(UINT32 recipientChannel = 0) :
- LMEMessage(APF_CHANNEL_CLOSE),
- RecipientChannel(recipientChannel) {}
-
- UINT32 RecipientChannel;
-};
-
-struct LMEChannelDataMessage : LMEMessage {
-
- LMEChannelDataMessage(UINT32 recipientChannel = 0,
- UINT32 dataLength = 0,
- UINT8 *data = NULL) :
- LMEMessage(APF_CHANNEL_DATA),
- RecipientChannel(recipientChannel),
- DataLength(dataLength)
- {
- if ((data != NULL) && (dataLength != 0)) {
- Data = new UINT8[dataLength];
- memcpy(Data, data, dataLength);
- } else {
- Data = NULL;
- }
- }
-
- ~LMEChannelDataMessage()
- {
- if (Data != NULL) {
- delete[] Data;
- Data = NULL;
- }
- }
-
- const UINT32 RecipientChannel;
- const UINT32 DataLength;
- UINT8 *Data;
-};
-
-struct LMEChannelWindowAdjustMessage : LMEMessage {
-
- LMEChannelWindowAdjustMessage(UINT32 recipientChannel = 0,
- UINT32 bytesToAdd = 0) :
- LMEMessage(APF_CHANNEL_WINDOW_ADJUST),
- RecipientChannel(recipientChannel),
- BytesToAdd(bytesToAdd) {}
-
- UINT32 RecipientChannel;
- UINT32 BytesToAdd;
-};
-
-typedef void (*HECICallback)(void *param, void *buffer, unsigned int len, int *status);
-
-class LMEConnection
-{
-public:
- LMEConnection(bool verbose = false);
- ~LMEConnection();
-
- bool Init(HECICallback cb, void *param);
- bool IsInitialized();
- bool Disconnect(APF_DISCONNECT_REASON_CODE reasonCode);
- bool ServiceAccept(std::string serviceName);
- bool UserAuthSuccess();
- bool ProtocolVersion(const LMEProtocolVersionMessage versionMessage);
- bool TcpForwardReplySuccess(UINT32 port);
- bool TcpForwardReplyFailure();
- bool TcpForwardCancelReplySuccess();
- bool TcpForwardCancelReplyFailure();
- bool ChannelOpenForwardedRequest(UINT32 sender, UINT32 connectedPort,
- std::string originatorIP, UINT32 originatorPort);
- bool ChannelOpenReplaySuccess(UINT32 recipient, UINT32 sender);
- bool ChannelOpenReplayFailure(UINT32 recipient, UINT32 reason);
- bool ChannelClose(UINT32 recipient);
- int ChannelData(UINT32 recipient, UINT32 len, unsigned char *buffer);
- bool ChannelWindowAdjust(UINT32 recipient, UINT32 len);
-
- //BACKWARD COMPATIBLE PUBLIC - BEGIN
- bool CompatProtocolVersion();
- bool CompatRequestIPFQDN();
- bool CompatOpenConnection(in_port_t mePort, ATAddress addr, unsigned int &connID);
- int CompatSendMessage(UINT8 connID, UINT32 len, unsigned char *buffer);
- void CompatCloseConnection(int connID, int status);
- //BACKWARD COMPATIBLE PUBLIC - END
-
- void Deinit();
- unsigned int GetHeciBufferSize() const;
-
- enum INIT_STATES {
- INIT_STATE_DISCONNECTED = 0,
- INIT_STATE_CONNECTING,
- INIT_STATE_CONNECTED
- };
-
- static const UINT32 RX_WINDOW_SIZE;
-
- unsigned char protocolVer;
-
-private:
- static const GUID _guid;
-
- static void _rxThreadFunc(void *param);
-
- void _doRX();
- int _receiveMessage(unsigned char *buffer, int len);
- int _sendMessage(unsigned char *buffer, int len);
- bool _checkMinMsgSize(unsigned char *buf, unsigned int bytesRead);
- void _apfGlobalRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfUserAuthRequest(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfChannelOpen(unsigned char *rxBuffer, unsigned int bytesRead, int *status);
- void _apfChannelOpenDirect(unsigned char *rxBuffer, unsigned int bytesRead, UINT32 *senderChannel, int *status);
-
-
- unsigned char _reqID;
- unsigned char *_txBuffer;
- Thread *_rxThread;
- HECICallback _cb;
- void *_cbParam;
- Semaphore _initLock;
- Semaphore _sendMessageLock;
- INIT_STATES _initState;
- Event _threadStartedEvent;
-#if defined(__sun) || defined(_LINUX)
- HECILinux _heci;
-#else
- HECIWin _heci;
-#endif
-
- //BACKWARD COMPATIBLE PRIVATE - BEGIN
- static const GUID _guidCompat;
-
- void _doRXCompat();
-
- struct CompatConnection {
- Event *event;
- int connID;
- UINT8 status;
- };
- typedef std::map<int, CompatConnection> CompatConnMap;
- CompatConnMap _compatPendingConnections;
- Semaphore _compatMapLock;
-#if defined(__sun) || defined(_LINUX)
- HECILinux _heciCompat;
-#else
- HECIWin _heciCompat;
-#endif
- //BACKWARD COMPATIBLE PRIVATE - END
-
- HECI *_pHeci;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/LMEConnectionCompat.cpp b/usr/src/cmd/lms/LMEConnectionCompat.cpp
deleted file mode 100644
index 6a91067872..0000000000
--- a/usr/src/cmd/lms/LMEConnectionCompat.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cerrno>
-#include "types.h"
-#include "LMEConnection.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "glue.h"
-
-#ifdef _LINUX
-#define _strnicmp strncasecmp
-#endif
-
-extern glue plugin;
-
-const GUID LMEConnection::_guidCompat = {0x3d98d9b7, 0x1ce8, 0x4252, {0xb3, 0x37, 0x2e, 0xff, 0x10, 0x6e, 0xf2, 0x9f}};
-
-int LMEConnection::CompatSendMessage(UINT8 connID, UINT32 len, unsigned char *buffer)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return -1;
- }
-
- unsigned char sendBuf[1024 + sizeof(LMS_SEND_DATA_MESSAGE)];
- LMS_SEND_DATA_MESSAGE *msg;
-
- if (len > 1024) {
- return -1;
- }
-
- msg = (LMS_SEND_DATA_MESSAGE *)sendBuf;
- msg->MessageType = LMS_MESSAGE_TYPE_SEND_DATA;
- msg->ConnectionId = connID;
- msg->DataLength = htons(len);
- memcpy(msg->Data, buffer, len);
-
- return _sendMessage(sendBuf, sizeof(LMS_SEND_DATA_MESSAGE) + len);
-}
-
-void LMEConnection::CompatCloseConnection(int connID, int status)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return;
- }
-
- LMS_CLOSE_CONNECTION_MESSAGE msg;
-
- msg.MessageType = LMS_MESSAGE_TYPE_CLOSE_CONNECTION;
- msg.ConnectionId = connID;
- msg.ClosingReason = status;
-
- _sendMessage((unsigned char *)&msg, sizeof(msg));
-}
-
-bool LMEConnection::CompatProtocolVersion()
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- LMS_PROTO_VERSION_MESSAGE msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.MessageType = LMS_MESSAGE_TYPE_PROTO_VERSION;
- msg.ConnectionId = 0;
- msg.Protocol = 0;
-
- PRINT("[Compat]Sending Protocol Version to LME\n");
- int bytesWritten = _sendMessage((unsigned char *)&msg, sizeof(msg));
- return (bytesWritten == sizeof(msg));
-}
-
-bool LMEConnection::CompatRequestIPFQDN()
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- LMS_IP_FQDN_REQUEST_MESSAGE msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.MessageType = LMS_MESSAGE_TYPE_IP_FQDN_REQUEST;
- msg.ConnectionId = 0;
-
- PRINT("[Compat]Sending IP_FQDN request to LME\n");
- int bytesWritten = _sendMessage((unsigned char *)&msg, sizeof(msg));
- return (bytesWritten == sizeof(msg));
-}
-
-bool LMEConnection::CompatOpenConnection(in_port_t mePort, ATAddress addr, unsigned int &connID)
-{
- if (!IsInitialized()) {
- PRINT("[Compat]State: not connected to HECI.\n");
- return false;
- }
-
- unsigned char currReqID = _reqID++;
- bool ret = false;
- LMS_OPEN_CONNECTION_EX_MESSAGE openConnectionExMsg;
- LMS_OPEN_CONNECTION_MESSAGE openConnectionMsg;
- unsigned char *msg = NULL;
- int msgLen = 0;
- size_t addrSize = 0;
- const void *inAddr = addr.inAddr(addrSize);
-
- if (protocolVer == LMS_PROCOL_VERSION_COMPAT) {
- memset(&openConnectionExMsg, 0, sizeof(openConnectionExMsg));
- openConnectionExMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX;
- openConnectionExMsg.ConnectionId = 0;
- openConnectionExMsg.Protocol = LMS_PROTOCOL_TYPE_TCP_IPV4;
- openConnectionExMsg.Flags = 0;
- openConnectionExMsg.OpenRequestId = currReqID;
- memcpy(openConnectionExMsg.Host, inAddr, addrSize);
- openConnectionExMsg.HostPort = htons(addr.inPort());
- openConnectionExMsg.MEPort = htons(mePort);
-
- msg = (unsigned char *)&openConnectionExMsg;
- msgLen = sizeof(openConnectionExMsg);
- PRINT("[Compat]OpenConnectionEx %x (%d) p=%d mp=%d\n",
- *(int *)inAddr, addrSize, addr.inPort(), mePort);
- }
- else {
- memset(&openConnectionMsg, 0, sizeof(openConnectionMsg));
- openConnectionMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION;
- openConnectionMsg.ConnectionId = 0;
- openConnectionMsg.Protocol = LMS_PROTOCOL_TYPE_TCP_IPV4;
- openConnectionMsg.OpenRequestId = currReqID;
- memcpy(openConnectionMsg.HostIPAddress, inAddr, addrSize);
- openConnectionMsg.HostPort = htons(addr.inPort());
- openConnectionMsg.MEPort = htons(mePort);
-
- msg = (unsigned char *)&openConnectionMsg;
- msgLen = sizeof(openConnectionMsg);
- PRINT("[Compat]OpenConnection %x (%d) p=%d mp=%d\n",
- *(int *)inAddr, addrSize, addr.inPort(), mePort);
- }
-
- // save as pending request
- CompatConnection conn;
- conn.event = new Event();
- conn.status = LMS_CONNECTION_STATUS_FAILED;
- conn.connID = 0;
-
- _compatMapLock.acquire();
- _compatPendingConnections[currReqID] = conn;
- _compatMapLock.release();
-
- int bytesWritten;
- bytesWritten = _sendMessage(msg, msgLen);
- if (bytesWritten != msgLen) {
- goto out;
- }
-
- if (conn.event->wait(10000) == false) {
- // no response from FW
- goto out;
- }
-
- ret = true;
-
-out:
- {
- Lock ml(_compatMapLock);
-
- if (_compatPendingConnections[currReqID].status != LMS_CONNECTION_STATUS_OK) {
- ret = false;
- } else {
- connID = _compatPendingConnections[currReqID].connID;
- }
- _compatPendingConnections.erase(currReqID);
- }
-
- delete conn.event;
- conn.event = NULL;
-
- return ret;
-}
-
-void LMEConnection::_doRXCompat()
-{
- unsigned int bytesRead;
- int status = 1;
-
- _threadStartedEvent.set();
-
- unsigned char *rxBuffer = new unsigned char[_heciCompat.GetBufferSize()];
-
- while (true) {
- bytesRead = (unsigned int)_receiveMessage(rxBuffer, _heciCompat.GetBufferSize());
-
- if ((int)bytesRead < 0) {
- PRINT("[Compat]Error receiving data from HECI\n");
- Deinit();
- break;
- }
-
- if (bytesRead == 0) {
- // ERROR
- continue;
- }
-
- PRINT("[Compat]Received from LME %d bytes (msg type %02d)\n", bytesRead, rxBuffer[0]);
-
- if (bytesRead < 2) {
- // ERROR
- continue;
- }
-
- if (plugin.preprocess(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- }
-
- switch (rxBuffer[0]) {
- case LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY:
- CompatRequestIPFQDN();
- break;
-
- case LMS_MESSAGE_TYPE_CLOSE_CONNECTION:
- case LMS_MESSAGE_TYPE_SEND_DATA:
- case LMS_MESSAGE_TYPE_IP_FQDN:
- _cb(_cbParam, rxBuffer, bytesRead, &status);
- break;
-
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY:
- {
- LMS_OPEN_CONNECTION_REPLY_MESSAGE *repMsg =
- (LMS_OPEN_CONNECTION_REPLY_MESSAGE *)rxBuffer;
-
- Lock ml(_compatMapLock);
-
- CompatConnMap::iterator itr;
- itr = _compatPendingConnections.find(repMsg->OpenRequestId);
- if (itr != _compatPendingConnections.end()) {
- (*itr).second.connID = repMsg->ConnectionId;
- (*itr).second.status = repMsg->Status;
- (*itr).second.event->set();
- PRINT("[Compat]Open connection reply %d %d =%d\n", repMsg->OpenRequestId, repMsg->ConnectionId, repMsg->Status);
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX:
- {
- // report incoming connection request
- _cb(_cbParam, rxBuffer, bytesRead, &status);
-
- if (IsInitialized() && (status == 1)) {
- if (plugin.retry(rxBuffer, bytesRead) == LMS_DROPPED) {
- continue;
- } else {
- _cb(_cbParam, rxBuffer, bytesRead, &status);
- }
- }
-
- LMS_OPEN_CONNECTION_EX_MESSAGE *msg =
- (LMS_OPEN_CONNECTION_EX_MESSAGE *)rxBuffer;
-
- if ((msg->Flags & HOSTNAME_BIT) != 0) {
- PRINT("[Compat]Got client connection request %d for host %s, port %d\n",
- msg->ConnectionId, msg->Host, ntohs(msg->HostPort));
- }
- else {
- PRINT("[Compat]Got client connection request %d for IP %s, port %d\n",
- msg->ConnectionId, inet_ntoa(*((struct in_addr *)msg->Host)), ntohs(msg->HostPort));
- }
-
- LMS_OPEN_CONNECTION_REPLY_MESSAGE repMsg;
- memset(&repMsg, 0, sizeof(repMsg));
-
- repMsg.MessageType = LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY;
- repMsg.ConnectionId = msg->ConnectionId;
- if (status == 0) {
- repMsg.Status = LMS_CONNECTION_STATUS_OK;
- } else {
- repMsg.Status = LMS_CONNECTION_STATUS_FAILED;
- }
-
- DWORD bytesWritten;
- bytesWritten = _sendMessage((unsigned char *)&repMsg, sizeof(repMsg));
- if (bytesWritten != sizeof(repMsg)) {
- PRINT("[Compat]Send Open Connection Reply failed: bytesWritten: %lu\n", bytesWritten);
- }
- }
- break;
-
- default:
- // Uknown request. Ignore
- break;
- }
-
- if (IsInitialized()) {
- plugin.postprocess(rxBuffer, bytesRead, status);
- }
- }
-
- if (rxBuffer != NULL) {
- delete[] rxBuffer;
- }
-}
-
diff --git a/usr/src/cmd/lms/LMS_if.h b/usr/src/cmd/lms/LMS_if.h
deleted file mode 100644
index a1d7ceefc2..0000000000
--- a/usr/src/cmd/lms/LMS_if.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _LMS_IF_H_
-#define _LMS_IF_H_
-
-#include "types.h"
-#include "LMS_if_constants.h"
-
-// disable the "zero-sized array" warning in Visual C++
-#ifdef _MSC_VER
-#pragma warning(disable:4200)
-#endif
-
-#pragma pack(1)
-
-typedef struct {
- UINT8 MessageType;
-} APF_MESSAGE_HEADER;
-
-
-/**
- * APF_GENERIC_HEADER - generic request header (note that its not complete header per protocol (missing WantReply)
- *
- * @MessageType:
- * @RequestStringLength: length of the string identifies the request
- * @RequestString: the string that identifies the request
- **/
-
-typedef struct {
- UINT8 MessageType;
- UINT32 StringLength;
- UINT8 String[0];
-} APF_GENERIC_HEADER;
-
-/**
- * TCP forward reply message
- * @MessageType - Protocol's Major version
- * @PortBound - the TCP port was bound on the server
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 PortBound;
-} APF_TCP_FORWARD_REPLY_MESSAGE;
-
-/**
- * response to ChannelOpen when channel open succeed
- * @MessageType - APF_CHANNEL_OPEN_CONFIRMATION
- * @RecipientChannel - channel number given in the open request
- * @SenderChannel - channel number assigned by the sender
- * @InitialWindowSize - Number of bytes in the window
- * @Reserved - Reserved
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 SenderChannel;
- UINT32 InitialWindowSize;
- UINT32 Reserved;
-} APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE;
-
-/**
- * response to ChannelOpen when a channel open failed
- * @MessageType - APF_CHANNEL_OPEN_FAILURE
- * @RecipientChannel - channel number given in the open request
- * @ReasonCode - code for the reason channel could not be open
- * @Reserved - Reserved
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 ReasonCode;
- UINT32 Reserved;
- UINT32 Reserved2;
-} APF_CHANNEL_OPEN_FAILURE_MESSAGE;
-
-/**
- * close channel message
- * @MessageType - APF_CHANNEL_CLOSE
- * @RecipientChannel - channel number given in the open request
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 RecipientChannel;
-} APF_CHANNEL_CLOSE_MESSAGE;
-
-/**
- * used to send/receive data.
- * @MessageType - APF_CHANNEL_DATA
- * @RecipientChannel - channel number given in the open request
- * @Length - Length of the data in the message
- * @Data - The data in the message
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 DataLength;
- UINT8 Data[0];
-} APF_CHANNEL_DATA_MESSAGE;
-
-/**
- * used to adjust receive window size.
- * @MessageType - APF_WINDOW_ADJUST
- * @RecipientChannel - channel number given in the open request
- * @BytesToAdd - number of bytes to add to current window size value
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 RecipientChannel;
- UINT32 BytesToAdd;
-} APF_WINDOW_ADJUST_MESSAGE;
-
-/**
- * This message causes immediate termination of the connection with AMT.
- * @ReasonCode - A Reason code for the disconnection event
- * @Reserved - Reserved must be set to 0
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 ReasonCode;
- UINT16 Reserved;
-} APF_DISCONNECT_MESSAGE;
-
-/**
- * Used to request a service identified by name
- * @ServiceNameLength - The length of the service name string.
- * @ServiceName - The name of the service being requested.
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 ServiceNameLength;
- UINT8 ServiceName[0];
-} APF_SERVICE_REQUEST_MESSAGE;
-
-/**
- * Used to send a service accept identified by name
- * @ServiceNameLength - The length of the service name string.
- * @ServiceName - The name of the service being requested.
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 ServiceNameLength;
- UINT8 ServiceName[0];
-} APF_SERVICE_ACCEPT_MESSAGE;
-
-/**
- * holds the protocl major and minor version implemented by AMT.
- * @MajorVersion - Protocol's Major version
- * @MinorVersion - Protocol's Minor version
- * @Trigger - The open session reason
- * @UUID - System Id
- **/
-typedef struct {
- UINT8 MessageType;
- UINT32 MajorVersion;
- UINT32 MinorVersion;
- UINT32 TriggerReason;
- UINT8 UUID[16];
- UINT8 Reserved[64];
-} APF_PROTOCOL_VERSION_MESSAGE;
-
-/**
- * holds the user authentication request.
- * @UsernameLength - The length of the user name string.
- * @Username - The name of the user in ASCII encoding.
- * Maximum allowed size is 64 bytes.
- * @ServiceNameLength - The length of the service name string.
- * @ServiceName - The name of the service to authorize.
- * @MethodNameLength - The length of the method name string.
- * @MethodName - The authentication method to use.
- **/
-//typedef struct {
-// UINT8 MessageType;
-// UINT32 UsernameLength;
-// UINT8 Username[0];
-// UINT32 ServiceNameLength;
-// UINT8 ServiceName[0];
-// UINT32 MethodNameLength;
-// UINT8 MethodName[0];
-//} APF_USERAUTH_REQUEST_MESSAGE;
-
-/**
- * holds the user authentication request failure reponse.
- * @MethodNameListLength - The length of the methods list string.
- * @MethodNameList - A comma seperated string of authentication
- * methods supported by the server in ASCII.
- **/
-//typedef struct {
-// UINT8 MessageType;
-// UINT32 MethodNameListLength;
-// UINT8 MethodNameList[0];
-// UINT8 Reserved;
-//} APF_USERAUTH_FAILURE_MESSAGE;
-
-/**
- * holds the user authentication request success reponse.
- **/
-typedef struct {
- UINT8 MessageType;
-} APF_USERAUTH_SUCCESS_MESSAGE;
-
-#pragma pack()
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMS_if_compat.h b/usr/src/cmd/lms/LMS_if_compat.h
deleted file mode 100644
index b6224fa470..0000000000
--- a/usr/src/cmd/lms/LMS_if_compat.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _LMS_IF_COMPAT_H_
-#define _LMS_IF_COMPAT_H_
-
-#include "types.h"
-
-// disable the "zero-sized array" warning in Visual C++
-#ifdef _MSC_VER
-#pragma warning(disable:4200)
-#endif
-
-#pragma pack(1)
-
-typedef enum {
- LMS_MESSAGE_TYPE_OPEN_CONNECTION = 0x01,
- LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY = 0x02,
- LMS_MESSAGE_TYPE_CLOSE_CONNECTION = 0x03,
- LMS_MESSAGE_TYPE_SEND_DATA = 0x04,
- LMS_MESSAGE_TYPE_IP_FQDN_REQUEST = 0x05,
- LMS_MESSAGE_TYPE_IP_FQDN = 0x06,
- LMS_MESSAGE_TYPE_PROTO_VERSION = 0x07,
- LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY = 0x08,
- LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX = 0x0a
-} LMS_MESSAGE_TYPE;
-
-typedef enum {
- LMS_PROTOCOL_TYPE_TCP_IPV4 = 0x00,
- LMS_PROTOCOL_TYPE_UDP_IPV4 = 0x01,
- LMS_PROTOCOL_TYPE_TCP_IPV6 = 0x02,
- LMS_PROTOCOL_TYPE_UDP_IPV6 = 0x03
-} LMS_PROTOCOL_TYPE;
-
-typedef enum {
- LMS_CONNECTION_STATUS_OK = 0x00,
- LMS_CONNECTION_STATUS_FAILED = 0x01,
- LMS_CONNECTION_STATUS_TOO_MANY = 0x02
-} LMS_CONNECTION_STATUS;
-
-typedef enum {
- LMS_CLOSE_STATUS_CLIENT = 0x00,
- LMS_CLOSE_STATUS_INTERNAL = 0x01,
- LMS_CLOSE_STATUS_SOCKET = 0x02,
- LMS_CLOSE_STATUS_SHUTDOWN = 0x03
-} LMS_CLOSE_STATUS;
-
-typedef enum {
- LMS_IP_ADDRESS_SHARED = 0x00,
- LMS_IP_ADDRESS_DUAL_IPV4 = 0x01,
- LMS_IP_ADDRESS_DUAL_IPV6 = 0x02
-} LMS_IP_ADDRESS_TYPE;
-
-typedef enum {
- LMS_PROTOCOL_STATUS_OK = 0x00,
- LMS_PROTOCOL_STATUS_PROPOSE_ANOTHER = 0x01
-} LMS_PROTOCOL_STATUS;
-
-/**
- * LMS_OPEN_CONNECTION_MESSAGE - open connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION
- * @ConnectionId: 0 if sent from LMS, positive if sent from LME
- * @Protocol: One of LMS_PROTOCOL_TYPE
- * @OpenRequestId: Any number; used to match the request to the response
- * @HostIPAddress: Source IP address of the initiating application, in network
- * order (Big Endian). If IPv4, only the first 4 bytes are used
- * and the rest must be 0.
- * @HostPort: Source port of the initiating application, in network order (Big
- * Endian).
- * @MEPort: Destination port of the initiating application, in network order
- * (Big Endian).
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 OpenRequestId;
- UINT8 HostIPAddress[16];
- UINT16 HostPort;
- UINT16 MEPort;
-} LMS_OPEN_CONNECTION_MESSAGE;
-
-/**
- * LMS_OPEN_CONNECTION_REPLY_MESSAGE - open connection reply
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_REPLY
- * @ConnectionId: Assigned by LME
- * @Status: One of LMS_CONNECTION_STATUS
- * @OpenRequestId: The same as the OpenRequestID value in the open connection
- * request message.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Status;
- UINT8 OpenRequestId;
-} LMS_OPEN_CONNECTION_REPLY_MESSAGE;
-
-/**
- * LMS_OPEN_CONNECTION_EX_MESSAGE - open connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX
- * @ConnectionId: Unique identifier
- * @Protocol: One of LMS_PROTOCOL_TYPE
- * @Flags: If first bit is set then Host is an hostname, otherwise Host is an IP address.
- * If second bit is set then connection is from remote console, otherwise
- * it is from local application. The other bits must be zero.
- * @Reserved: Must be zero
- * @OpenRequestId: Any number; used to match the request to the response
- * @Host: Source IP address of the initiating application, in network
- * order (Big Endian). If IPv4, only the first 4 bytes are used
- * and the rest must be 0.
- * @HostPort: Source port of the initiating application, in network order (Big
- * Endian).
- * @MEPort: Destination port of the initiating application, in network order
- * (Big Endian).
- */
-
-#define HOSTNAME_BIT 0x1
-#define REMOTE_BIT 0x2
-
-#define FQDN_MAX_SIZE 256
-
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 Flags;
- UINT32 Reserved;
- UINT8 OpenRequestId;
- UINT8 Host[FQDN_MAX_SIZE];
- UINT16 HostPort;
- UINT16 MEPort;
-} LMS_OPEN_CONNECTION_EX_MESSAGE;
-
-///**
-// * LMS_OPEN_CONNECTION_EX_REPLY_MESSAGE - open connection reply
-// *
-// * @MessageType: LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX_REPLY
-// * @ConnectionId: Should match value in connection request
-// * @Status: One of LMS_CONNECTION_STATUS
-// * @OpenRequestId: The same as the OpenRequestID value in the open connection
-// * request message.
-// */
-//typedef struct {
-// UINT8 MessageType;
-// UINT8 ConnectionId;
-// UINT8 Status;
-// UINT8 OpenRequestId;
-//} LMS_OPEN_CONNECTION_EX_REPLY_MESSAGE;
-
-/**
- * LMS_CLOSE_CONNECTION_MESSAGE - close connection request
- *
- * @MessageType: LMS_MESSAGE_TYPE_CLOSE_CONNECTION
- * @ConnectionId: The connection ID chosen by the LME when the connection
- * was established.
- * @ClosingReason: One of LMS_CLOSE_STATUS
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 ClosingReason;
-} LMS_CLOSE_CONNECTION_MESSAGE;
-
-/**
- * LMS_SEND_DATA_MESSAGE - sends data betwen LMS and LME
- *
- * @MessageType: LMS_MESSAGE_TYPE_SEND_DATA
- * @ConnectionId: The connection ID chosen by the LME when the connection
- * was established.
- * @DataLength: Length of data field, in Big Endian.
- * @Data: The data to transfer
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT16 DataLength;
- UINT8 Data[0];
-} LMS_SEND_DATA_MESSAGE;
-
-/**
- * LMS_IP_FQDN_REQUEST_MESSAGE - Requests IP/FQDN data
- *
- * @MessageType: LMS_MESSAGE_TYPE_IP_FQDN_REQUEST
- * @ConnectionId: Must be 0.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
-} LMS_IP_FQDN_REQUEST_MESSAGE;
-
-/**
- * LMS_IP_FQDN_MESSAGE - sends IP/FQDN info
- *
- * @MessageType: LMS_MESSAGE_TYPE_IP_FQDN
- * @ConnectionId: Must be 0.
- * @IPType: One of LMS_IP_ADDRESS_TYPE.
- * @Reserved: Must be 0.
- * @AMTIPAddress: The Intel(R) AMT IP address, in network order (Big Endian).
- * If IPv4, then only the first 4 bytes are used and the rest
- * must be 0.
- * @FQDN: A NUL terminated string specifying the Fully Qualified Domain Name.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 IPType;
- UINT8 Reserved;
- UINT8 AMTIPAddress[16];
- UINT8 FQDN[FQDN_MAX_SIZE];
-} LMS_IP_FQDN_MESSAGE;
-
-/**
- * LMS_PROTO_VERSION_MESSAGE - sends protocol version information
- *
- * @MessageType: LMS_MESSAGE_TYPE_PROTO_VERSION
- * @ConnectionId: Must be 0.
- * @Protocol: Protocol version.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
-} LMS_PROTO_VERSION_MESSAGE;
-
-/**
- * LMS_PROTO_VERSION_REPLY_MESSAGE - sends protocol version information
- *
- * @MessageType: LMS_MESSAGE_TYPE_PROTO_VERSION_REPLY
- * @ConnectionId: Must be 0.
- * @Protocol: Protocol version.
- * @Status: One of LMS_PROTOCOL_STATUS.
- */
-typedef struct {
- UINT8 MessageType;
- UINT8 ConnectionId;
- UINT8 Protocol;
- UINT8 Status;
-} LMS_PROTO_VERSION_REPLY_MESSAGE;
-
-#pragma pack()
-
-#endif
-
diff --git a/usr/src/cmd/lms/LMS_if_constants.h b/usr/src/cmd/lms/LMS_if_constants.h
deleted file mode 100644
index 6cc34c850a..0000000000
--- a/usr/src/cmd/lms/LMS_if_constants.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _LMS_IF_CONSTANTS_H_
-#define _LMS_IF_CONSTANTS_H_
-
-#define LMS_PROCOL_VERSION 4
-#define LMS_PROCOL_VERSION_COMPAT 2
-
-//
-// messages opcodes
-//
-typedef enum {
- APF_DISCONNECT = 1,
- APF_SERVICE_REQUEST = 5,
- APF_SERVICE_ACCEPT = 6,
- APF_USERAUTH_REQUEST = 50,
- APF_USERAUTH_FAILURE = 51,
- APF_USERAUTH_SUCCESS = 52,
- APF_GLOBAL_REQUEST = 80,
- APF_REQUEST_SUCCESS = 81,
- APF_REQUEST_FAILURE = 82,
- APF_CHANNEL_OPEN = 90,
- APF_CHANNEL_OPEN_CONFIRMATION = 91,
- APF_CHANNEL_OPEN_FAILURE = 92,
- APF_CHANNEL_WINDOW_ADJUST = 93,
- APF_CHANNEL_DATA = 94,
- APF_CHANNEL_CLOSE = 97,
- APF_PROTOCOLVERSION = 192
-} APF_MESSAGE_TYPE;
-
-typedef enum {
- APF_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1,
- APF_DISCONNECT_PROTOCOL_ERROR = 2,
- APF_DISCONNECT_KEY_EXCHANGE_FAILED = 3,
- APF_DISCONNECT_RESERVED = 4,
- APF_DISCONNECT_MAC_ERROR = 5,
- APF_DISCONNECT_COMPRESSION_ERROR = 6,
- APF_DISCONNECT_SERVICE_NOT_AVAILABLE = 7,
- APF_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8,
- APF_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9,
- APF_DISCONNECT_CONNECTION_LOST = 10,
- APF_DISCONNECT_BY_APPLICATION = 11,
- APF_DISCONNECT_TOO_MANY_CONNECTIONS = 12,
- APF_DISCONNECT_AUTH_CANCELLED_BY_USER = 13,
- APF_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14,
- APF_DISCONNECT_ILLEGAL_USER_NAME = 15
-} APF_DISCONNECT_REASON_CODE;
-
-//
-//strings used in global messages
-//
-#define APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST "tcpip-forward"
-#define APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST "cancel-tcpip-forward"
-#define APF_GLOBAL_REQUEST_STR_UDP_SEND_TO "udp-send-to@amt.intel.com"
-#define APF_OPEN_CHANNEL_REQUEST_FORWARDED "forwarded-tcpip"
-#define APF_OPEN_CHANNEL_REQUEST_DIRECT "direct-tcpip"
-
-// APF service names
-#define APF_SERVICE_PFWD "pfwd@amt.intel.com"
-#define APF_SERVICE_AUTH "auth@amt.intel.com"
-
-// APF Authentication method
-#define APF_AUTH_NONE "none"
-#define APF_AUTH_PASSWORD "password"
-
-//calculate string length without the NULL terminator
-#define APF_STR_SIZE_OF(s) (sizeof(s)-1)
-
-// Trigger reason code
-typedef enum {
- USER_INITIATED_REQUEST = 1,
- ALERT_REQUEST = 2,
- HIT_PROVISIONING_REQUEST = 3,
- PERIODIC_REQUEST = 4,
- LME_REQUEST = 254
-} APF_TRIGGER_REASON;
-
-typedef enum {
- OPEN_FAILURE_REASON_ADMINISTRATIVELY_PROHIBITED = 1,
- OPEN_FAILURE_REASON_CONNECT_FAILED = 2,
- OPEN_FAILURE_REASON_UNKNOWN_CHANNEL_TYPE = 3,
- OPEN_FAILURE_REASON_RESOURCE_SHORTAGE = 4
-} OPEN_FAILURE_REASON;
-
-#endif
-
diff --git a/usr/src/cmd/lms/Makefile b/usr/src/cmd/lms/Makefile
deleted file mode 100644
index 03c52c4b31..0000000000
--- a/usr/src/cmd/lms/Makefile
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-PROG= lms
-MANIFEST= lms.xml
-
-include ../Makefile.cmd
-
-LMSOBJS= ConfigConnection.o Protocol.o main.o \
- LMEConnection.o ProtocolCompat.o \
- LMEConnectionCompat.o glue.o \
- SyncLib/src/EventUnix.o SyncLib/src/RWLock.o \
- SyncLib/src/SemaphoreUnix.o SyncLib/src/ThreadUnix.o \
- heci/FWULCommand.o heci/HECIUnix.o \
- heci/MNGCommand.o heci/PTHICommand.o \
- tools/ATNetworkTool.o tools/ATVersion.o \
- tools/daemonize.o
-
-ROOTMANIFESTDIR= $(ROOTSVCNETWORK)
-ROOTMETHOD= $(ROOTLIBSVCMETHOD)/svc-lms
-$(ROOTMANIFEST) := FILEMODE= 444
-
-SYNCLIB_SRCDIR=SyncLib/src
-SYNCLIB_HDRDIR=SyncLib/Include
-HECI_DIR=heci
-TOOLS_DIR=tools
-
-CPPFLAGS= -DBSD_COMP -D_REMOTE_SUPPORT \
- -I. -I$(SYNCLIB_HDRDIR) -I$(HECI_DIR) -I$(TOOLS_DIR)
-CCFLAGS += -compat=5 -features=zla
-$(__SUNC)CCNEEDED= $(CCEXTNEEDED)
-LDFLAGS += $(ZIGNORE) -norunpath
-LDLIBS += -lsocket -lnsl
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-$(PROG): $(LMSOBJS)
- $(LINK.cc) -o $@ $(LMSOBJS) $(LDLIBS) -lc
- $(POST_PROCESS)
-
-%.o: %.cpp
- $(COMPILE.cc) $(OUTPUT_OPTION) -o $@ $<
- $(POST_PROCESS_O)
-
-install: all $(ROOTLIBPROG) $(ROOTMANIFEST) $(ROOTMETHOD)
-
-check: $(CHKMANIFEST)
-
-clean:
- $(RM) $(OBJS) $(LMSOBJS)
-
-include ../Makefile.targ
-
-#
-# we're not linting lms. it's all C++.
-#
-
-lint:
diff --git a/usr/src/cmd/lms/PortForwardRequest.h b/usr/src/cmd/lms/PortForwardRequest.h
deleted file mode 100644
index ce95dc1797..0000000000
--- a/usr/src/cmd/lms/PortForwardRequest.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _PORT_FORWARD_REQUEST_H_
-#define _PORT_FORWARD_REQUEST_H_
-
-#include <string>
-
-#if defined(__sun) || defined(_LINUX)
-#ifndef SOCKET
-#define SOCKET int
-#endif
-#endif
-
-typedef int (*IsConnectionPermittedCallback)(void * const param, SOCKET s);
-
-class PortForwardRequest
-{
-public:
- enum PORT_FORWARD_REQUEST_STATUS {
- NOT_ACTIVE,
- PENDING_REQUEST,
- LISTENING
- };
-
- PortForwardRequest(std::string bindedAddress, int port,
- SOCKET listeningSocket,
- IsConnectionPermittedCallback cb, bool isLocal) :
- _bindedAddress(bindedAddress),
- _port(port),
- _local(isLocal),
- _listeningSocket(listeningSocket),
- _cb(cb),
- _status(NOT_ACTIVE),
- _channelCount(0) {}
-
- const std::string GetBindedAddress() const { return _bindedAddress; }
- const unsigned int GetPort() const { return _port; }
- SOCKET GetListeningSocket() const { return _listeningSocket; }
-
- int IsConnectionPermitted(void *param, SOCKET s)
- {
- if (_cb != NULL) {
- return _cb(param, s);
- } else {
- return -1;
- }
- }
-
- PORT_FORWARD_REQUEST_STATUS GetStatus() { return _status; }
- bool IsLocal() { return _local; }
- bool SetStatus(PORT_FORWARD_REQUEST_STATUS newStatus) { _status = newStatus; return true; }
- unsigned int GetChannelCount() { return _channelCount; }
- unsigned int IncreaseChannelCount() { return ++_channelCount; }
-
- unsigned int DecreaseChannelCount()
- {
- if (_channelCount > 0) {
- --_channelCount;
- }
- return _channelCount;
- }
-
-
-private:
- const std::string _bindedAddress;
- const unsigned int _port;
- const bool _local;
- const SOCKET _listeningSocket;
- const IsConnectionPermittedCallback _cb;
- PORT_FORWARD_REQUEST_STATUS _status;
- unsigned int _channelCount;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/Protocol.cpp b/usr/src/cmd/lms/Protocol.cpp
deleted file mode 100644
index 3b611c9f6e..0000000000
--- a/usr/src/cmd/lms/Protocol.cpp
+++ /dev/null
@@ -1,1815 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#if defined(__sun) || defined(_LINUX)
-#include <cerrno>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <syslog.h>
-
-#define _stprintf_s snprintf
-#define strnicmp strncasecmp
-#else
-
-#include <winsock2.h>
-#include <iphlpapi.h>
-#include <Ws2tcpip.h>
-#include <tchar.h>
-
-#endif // __sun || _LINUX
-
-#include <fstream>
-#include <algorithm>
-#include "Protocol.h"
-#include "LMS_if.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "ATNetworkTool.h"
-
-const LMEProtocolVersionMessage Protocol::MIN_PROT_VERSION(1, 0);
-const LMEProtocolVersionMessage Protocol::MAX_PROT_VERSION(1, 0);
-
-Protocol::Protocol() :
-#if DEBUGLOG
-_lme(true),
-#else
-_lme(false),
-#endif
-_rxSocketBuffer(NULL),
-_rxSocketBufferSize(0)
-#ifdef _REMOTE_SUPPORT
-, _cfg(true)
-#endif
-{
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- _sockets_active = false;
- _handshakingStatus = NOT_INITIATED;
- _pfwdService = NOT_STARTED;
- _AmtProtVersion.MajorVersion = 0;
- _AmtProtVersion.MinorVersion = 0;
-#ifdef _REMOTE_SUPPORT
- _remoteAccessEnabled = false;
-#endif
- memset(_AMTFQDN, 0, sizeof(_AMTFQDN));
- oldProtocolMode = false;
- _deinitReq = false;
- _listenFailReported.clear();
-}
-
-Protocol::~Protocol()
-{
- if (!oldProtocolMode) {
- _lme.Disconnect(APF_DISCONNECT_BY_APPLICATION);
- }
- DeinitFull();
- DestroySockets();
- _listenFailReported.clear();
-}
-
-bool Protocol::Init(EventLogCallback cb, void *param)
-{
- _eventLog = cb;
- _eventLogParam = param;
-
- DeinitFull();
-
- {
- Lock dl(_deinitLock);
- _deinitReq = false;
- }
-
- if (!_lme.Init(_LmeCallback, this)) {
- return false;
- }
-
- oldProtocolMode = (LMS_PROCOL_VERSION != _lme.protocolVer);
-
- {
- Lock l(_versionLock);
-
- if (_handshakingStatus == NOT_INITIATED) {
- if (oldProtocolMode) {
- _lme.CompatProtocolVersion();
- } else {
- _lme.ProtocolVersion(MAX_PROT_VERSION);
- }
- _handshakingStatus = INITIATED;
- }
- }
-
- if (!oldProtocolMode) {
-#ifdef _REMOTE_SUPPORT
- if (!_cfg.Init(true)) {
-#else
- if (!_cfg.IsAMTEnabled(false)) {
-#endif
- _lme.Deinit();
- return false;
- }
- }
-
- long bufSize = _lme.GetHeciBufferSize() - sizeof(APF_CHANNEL_DATA_MESSAGE);
- if (bufSize > 0) {
- _rxSocketBuffer = new char[bufSize];
- _rxSocketBufferSize = bufSize;
- } else {
- DeinitFull();
- return false;
- }
-
-#ifdef _REMOTE_SUPPORT
- if (!oldProtocolMode) {
- _checkRemoteSupport(true);
- }
-#endif
- return true;
-}
-
-Channel *Protocol::_getSockOpenChannel(SOCKET s)
-{
- if (oldProtocolMode) {
- ChannelMap::iterator it = _openChannels.begin();
- for (; it != _openChannels.end(); it++) {
- if (it->second->GetSocket() == s) {
- return it->second;
- }
- }
- } else {
- ChannelMap::iterator it = _openChannels.find(s);
- if (it != _openChannels.end()) {
- return it->second;
- }
- }
- return NULL;
-}
-
-bool Protocol::IsDeInitialized()
-{
- Lock dl(_deinitLock);
- return _deinitReq;
-}
-
-
-bool Protocol::IsInitialized()
-{
- if (IsDeInitialized()) {
- return false;
- }
-
- return _lme.IsInitialized();
-}
-
-void Protocol::Deinit()
-{
- Lock dl(_deinitLock);
- _deinitReq = true;
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- ATNetworkTool::CloseSocket(_clientSignalSocket);
-
- {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.begin();
-
- for (; it != _openChannels.end(); it++) {
- ATNetworkTool::CloseSocket(it->second->GetSocket());
- delete it->second;
- }
-
- _openChannels.clear();
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- ATNetworkTool::CloseSocket(it->second[0]->GetListeningSocket());
-
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- delete *it2;
- }
- }
- }
- _openPorts.clear();
- }
-
- _lme.Deinit();
-
-#ifdef _REMOTE_SUPPORT
- if (!oldProtocolMode) {
- _cfg.Deinit();
- }
-#endif
-
- {
- Lock vl(_versionLock);
- _handshakingStatus = NOT_INITIATED;
- _pfwdService = NOT_STARTED;
- _AmtProtVersion.MajorVersion = 0;
- _AmtProtVersion.MinorVersion = 0;
- }
-
-}
-
-void Protocol::DeinitFull()
-{
- Deinit();
-
- if (_rxSocketBuffer != NULL) {
- delete []_rxSocketBuffer;
- _rxSocketBuffer = NULL;
- _rxSocketBufferSize = 0;
- }
-
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- _sockets_active = false;
-
-#ifdef _REMOTE_SUPPORT
- _remoteAccessEnabled = false;
-#endif
- memset(_AMTFQDN, 0, sizeof(_AMTFQDN));
-}
-
-bool Protocol::_checkListen(std::string address, in_port_t port, int &socket)
-{
- bool exists = false;
-
- PortMap::iterator it = _openPorts.find(port);
- if (it != _openPorts.end()) {
- if (it->second.size() > 0) {
- socket = it->second[0]->GetListeningSocket();
- PortForwardRequestList::iterator it2 = it->second.begin();
-
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetStatus() != PortForwardRequest::NOT_ACTIVE) &&
- ((*it2)->GetBindedAddress().compare(address) == 0)) {
- exists = true;
- break;
- }
- }
-
- }
- } else {
- PortForwardRequestList portForwardRequestList;
- _openPorts[port] = portForwardRequestList;
- }
-
- return exists;
-}
-
-int Protocol::_listenPort(in_port_t port, int &error)
-{
- return ATNetworkTool::CreateServerSocket(
- port,
- error,
- false, true, PF_INET);
-}
-
-bool Protocol::_localListen(in_port_t port)
-{
- int error;
- int socket = INVALID_SOCKET;
- bool exists = _checkListen("127.0.0.1", port, socket);
-
- int serverSocket = _listenPort(port, error);
- if (serverSocket == INVALID_SOCKET) {
- PRINT("[Compat]LMS Service cannot listen at port %d.\n", (int)port);
- if (exists) {
- //already listening
- }
- return false;
- }
- PRINT("[Compat]Listening at port %d at local interface.\n", (int)port);
-
- PortForwardRequest *portForwardRequest =
- new PortForwardRequest("127.0.0.1", port,
- serverSocket, _isLocalCallback, true);
-
- _openPorts[port].push_back(portForwardRequest);
- portForwardRequest->SetStatus(PortForwardRequest::LISTENING);
-
- return true;
-}
-
-bool Protocol::CreateSockets()
-{
- int error;
- _sockets_active = false;
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = ATNetworkTool::CreateServerSocket((in_port_t)0, error, true);
- if (_serverSignalSocket == INVALID_SOCKET) {
- return false;
- }
-
- ATNetworkTool::CloseSocket(_clientSignalSocket);
- _clientSignalSocket = ATNetworkTool::ConnectToSocket(_serverSignalSocket, error);
- if (_clientSignalSocket == INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- return false;
- }
-
- struct sockaddr_storage addr;
- socklen_t addrLen = sizeof(addr);
- SOCKET s_new = accept(_serverSignalSocket, (struct sockaddr *)&addr, &addrLen);
- if (s_new == INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- ATNetworkTool::CloseSocket(_clientSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- _clientSignalSocket = INVALID_SOCKET;
- return false;
- }
-
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = s_new;
-
- if (oldProtocolMode) {
- if (!_localListen(16992)) {
- return false;
- }
- if (!_localListen(16993)) {
- return false;
- }
- }
-
- _sockets_active = true;
- return true;
-}
-
-void Protocol::DestroySockets()
-{
- _sockets_active = false;
-
- if (_serverSignalSocket != INVALID_SOCKET) {
- ATNetworkTool::CloseSocket(_serverSignalSocket);
- _serverSignalSocket = INVALID_SOCKET;
- }
-}
-
-bool Protocol::_acceptConnection(SOCKET s, unsigned int port)
-{
- ATAddress addr;
- int error = 0;
- char buf[NI_MAXHOST];
-
- if (!IsInitialized()) {
- return false;
- }
-
- SOCKET s_new = ATNetworkTool::Accept(s, addr, error);
- if (s_new == INVALID_SOCKET) {
-#if DEBUGLOG
- char *msg = _getErrMsg(error);
- PRINT("Error accepting new connection (%d): %s\n", error, msg);
-#endif
- return false;
- }
-
- const char *addrStr = addr.inNtoP(buf, NI_MAXHOST);
- if (addrStr == NULL) {
- PRINT("Error: ntop failed for new connection\n");
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
-
- PortForwardRequest *portForwardRequest = NULL;
-
- //_portsLock is already aquired by the calling function: Select().
- PortMap::iterator it = _openPorts.find(port);
- if (it != _openPorts.end()) {
- PortForwardRequestList::iterator it2 = it->second.begin();
-
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetStatus() == PortForwardRequest::LISTENING) &&
- (1 == (*it2)->IsConnectionPermitted(this, s_new))) {
- portForwardRequest = *it2;
- break;
- }
- }
-
- }
-
- if (portForwardRequest == NULL) {
- PRINT("Error: new connection is denied (addr %s)\n", addrStr);
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
-
- if (oldProtocolMode) {
- unsigned int connId;
- bool oret = _lme.CompatOpenConnection(port, addr, connId);
- if (!oret) {
- PRINT("[Compat]Error: failed to open new LME MEI connection\n");
- ATNetworkTool::CloseSocket(s_new);
- return false;
- }
- PRINT("[Compat]Send open connection to LME. Sender %d.\n", (int)s_new);
-
- Channel *c = new Channel(portForwardRequest, s_new);
- c->SetStatus(Channel::OPEN);
- c->SetRecipientChannel(connId);
- c->AddBytesTxWindow(1024);
-
- Lock l(_channelsLock);
- _openChannels[connId] = c;
- c->GetPortForwardRequest()->IncreaseChannelCount();
- } else {
- Channel *c = new Channel(portForwardRequest, s_new);
- c->SetStatus(Channel::NOT_OPENED);
-
- Lock l(_channelsLock);
- _openChannels[s_new] = c;
- c->GetPortForwardRequest()->IncreaseChannelCount();
-
- _lme.ChannelOpenForwardedRequest((UINT32)s_new,
- port,
- ((portForwardRequest->IsLocal()) ? "127.0.0.1" : addrStr),
- addr.inPort());
- PRINT("Send channel open request to LME. Sender %d.\n", (int)s_new);
- }
-
- return true;
-}
-
-int Protocol::Select()
-{
- fd_set rset;
- struct timeval tv;
- int res;
- int fdCount = 0;
- int fdMin = -1;
-
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- FD_ZERO(&rset);
-
- FD_SET(_serverSignalSocket, &rset);
- if ((int)_serverSignalSocket > fdCount) {
- fdCount = (int)_serverSignalSocket;
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- SOCKET serverSocket = it->second[0]->GetListeningSocket();
- FD_SET(serverSocket, &rset);
- if ((int)serverSocket > fdCount) {
- fdCount = (int)serverSocket;
- }
- }
- }
- }
-
- {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.begin();
-
- for (; it != _openChannels.end(); it++) {
- if ((it->second->GetStatus() == Channel::OPEN) &&
- (it->second->GetTxWindow() > 0)) {
- SOCKET socket = it->second->GetSocket();
- FD_SET(socket, &rset);
- if ((int)socket > fdCount) {
- fdCount = (int)socket;
- }
- if ((fdMin == -1) || ((int)socket < fdMin)) {
- fdMin = (int)socket;
- }
- }
- }
- }
-
- fdCount++;
- res = select(fdCount, &rset, NULL, NULL, &tv);
- if (res == -1) {
-#if DEBUGLOG
-#if defined(__sun) || defined(_LINUX)
- int err = errno;
-#else
- int err = GetLastError();
-#endif // __sun || _LINUX
-
- char *msg = _getErrMsg(err);
- PRINT("Select error (%d): %s\n", err, msg);
-#endif
- return -1;
- }
-
- if (res == 0) {
- return 0;
- }
-
- if (!IsInitialized()) {
- return 0;
- }
-
- if (FD_ISSET(_serverSignalSocket, &rset)) { // Received a 'signal'
- char c = 0;
- res = recv(_serverSignalSocket, &c, 1, 0);
- FD_CLR(_serverSignalSocket, &rset);
- res--;
- }
-
- {
- Lock l(_portsLock);
- PortMap::iterator it = _openPorts.begin();
-
- for (; it != _openPorts.end(); it++) {
- if (it->second.size() > 0) {
- SOCKET serverSocket = it->second[0]->GetListeningSocket();
- if (FD_ISSET(serverSocket, &rset)) {
- // connection request
- PRINT("Connection requested on port %d\n", it->first);
- _acceptConnection(serverSocket, it->first);
- FD_CLR(serverSocket, &rset);
- res--;
- }
- }
- }
- }
-
- int i;
- for (i = fdMin/*0*/; (res > 0) && (i < fdCount); i++) {
- if (FD_ISSET(i, &rset)) {
- _rxFromSocket(i);
- res--;
- }
- }
-
- return 1;
-}
-
-int Protocol::_rxFromSocket(SOCKET s)
-{
- Channel *c = NULL;
-
- if (!IsInitialized()) {
- return 0;
- }
-
- {
- Lock l(_channelsLock);
-
- Channel *cx = _getSockOpenChannel(s);
-
- if (cx == NULL) {
- // Data received from a socket that is not in the map.
- // Since we only select on our sockets, this means it was
- // in the map, but was removed, probably because we received
- // an End Connection message from the HECI.
- return 0;
- }
-
- c = new Channel(*cx);
- }
-
- int res = 0;
-
- int len = std::min(c->GetTxWindow(), _rxSocketBufferSize);
- res = recv(s, _rxSocketBuffer, len, 0);
- if (res > 0) {
- // send data to LME
- PRINT("Received %d bytes from socket %d. Sending to LME\n", res, (int)s);
- if (oldProtocolMode) {
- _lme.CompatSendMessage((UINT8)c->GetRecipientChannel(), res, (unsigned char *)_rxSocketBuffer);
- } else {
- _lme.ChannelData(c->GetRecipientChannel(), res, (unsigned char *)_rxSocketBuffer);
- }
- goto out;
- } else if (res == 0) {
- // connection closed
- PRINT("Received 0 bytes from socket %d.\n", (int)s);
- goto out;
- } else {
-#if DEBUGLOG
-#if defined(__sun) || defined(_LINUX)
- int err = errno;
-#else
- int err = GetLastError();
-#endif // __sun || _LINUX
-
- char *msg = _getErrMsg(err);
- PRINT("Receive error on socket %d (%d): %s\n", (int)s, err, msg);
-#endif
-#ifdef __sun
- ATNetworkTool::CloseSocket(s);
-#endif
- goto out;
- }
-
-out:
- {
- Lock l(_channelsLock);
-
- Channel *cx = _getSockOpenChannel(s);
-
- if (cx == NULL) {
- // Data received from a socket that is not in the map.
- // Since we only select on our sockets, this means it was
- // in the map, but was removed, probably because we received
- // an End Connection message from the HECI.
- delete c;
- return 0;
- }
- if (res > 0) {
- if (!oldProtocolMode) {
- cx->AddBytesTxWindow(-res);
- }
- }
- else {
- cx->SetStatus(Channel::WAITING_CLOSE);
- if (oldProtocolMode) {
- if (res == 0) {
- _closeMChannel(cx);
-
- ChannelMap::iterator it = _openChannels.begin();
- for (; it != _openChannels.end(); it++) {
- if (it->second == cx) {
- break;
- }
- }
- if (it != _openChannels.end()) {
- _openChannels.erase(it);
- }
- }
- _lme.CompatCloseConnection(c->GetRecipientChannel(),
- ((res == 0) ? LMS_CLOSE_STATUS_CLIENT :
- LMS_CLOSE_STATUS_SOCKET));
- } else {
- _lme.ChannelClose(c->GetRecipientChannel());
- }
- }
- }
- delete c;
-
- return 0;
-}
-
-void Protocol::_signalSelect()
-{
- int senderr = 0;
-
- _send(_clientSignalSocket, "s", 1, senderr); //Enforce a new execution of Select()
-}
-
-void Protocol::_closePortForwardRequest(PortForwardRequest *p)
-{
- PortMap::iterator it = _openPorts.find(p->GetPort());
- if (it == _openPorts.end()) {
- return;
- }
-
- bool found = false;
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- if ((*it2) == p) {
- found = true;
- break;
- }
- }
-
- if ((*it2)->GetStatus() == PortForwardRequest::NOT_ACTIVE) {
-
- SOCKET serverSocket = (*it2)->GetListeningSocket();
- delete (*it2);
- it->second.erase(it2);
-
- if (it->second.size() == 0) {
- int res = ATNetworkTool::CloseSocket(serverSocket);
- if (res != 0) {
- int err;
-
-#if defined(__sun) || defined(_LINUX)
- err = errno;
-#else
- err = WSAGetLastError()
-#endif
- PRINT("Error %d in closing server socket at port %d.\n", err, p->GetPort());
- }
- _openPorts.erase(it);
- }
- }
-}
-
-bool Protocol::_checkProtocolFlow(LMEMessage *message)
-{
- switch (message->MessageType) {
- case APF_SERVICE_REQUEST:
- case APF_USERAUTH_REQUEST:
- {
- Lock l(_versionLock);
- if (_handshakingStatus != AGREED) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
- }
- break;
-
- case APF_GLOBAL_REQUEST:
- case APF_CHANNEL_OPEN:
- case APF_CHANNEL_OPEN_CONFIRMATION:
- case APF_CHANNEL_OPEN_FAILURE:
- case APF_CHANNEL_CLOSE:
- case APF_CHANNEL_DATA:
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- Lock l(_versionLock);
- if ((_handshakingStatus != AGREED) || (_pfwdService != STARTED)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
- }
- break;
-
- case APF_DISCONNECT:
- case APF_PROTOCOLVERSION:
- return true;
- break;
-
- default:
- {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- break;
- }
-
- return false;
-}
-
-unsigned int Protocol::_getMinMessageLen(LMEMessage *message)
-{
- switch (message->MessageType) {
- case APF_SERVICE_REQUEST:
- return sizeof(LMEServiceRequestMessage);
- break;
- case APF_USERAUTH_REQUEST:
- return sizeof(LMEUserAuthRequestMessage);
- break;
- case APF_GLOBAL_REQUEST:
- return sizeof(LMEGlobalRequestMessage);
- break;
- case APF_CHANNEL_OPEN:
- return sizeof(LMEChannelOpenRequestMessage);
- break;
- case APF_CHANNEL_OPEN_CONFIRMATION:
- return sizeof(LMEChannelOpenReplaySuccessMessage);
- break;
- case APF_CHANNEL_OPEN_FAILURE:
- return sizeof(LMEChannelOpenReplayFailureMessage);
- break;
- case APF_CHANNEL_CLOSE:
- return sizeof(LMEChannelCloseMessage);
- break;
- case APF_CHANNEL_DATA:
- return sizeof(LMEChannelDataMessage);
- break;
- case APF_CHANNEL_WINDOW_ADJUST:
- return sizeof(LMEChannelWindowAdjustMessage);
- break;
- case APF_DISCONNECT:
- return sizeof(LMEDisconnectMessage);
- break;
- case APF_PROTOCOLVERSION:
- return sizeof(LMEProtocolVersionMessage);
- break;
- default:
- return 0;
- }
-
- return 0;
-}
-
-bool Protocol::_checkMessageAndProtocol(LMEMessage *message, unsigned int len)
-{
- if (len < sizeof(LMEMessage)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
-
- if (!_checkProtocolFlow(message)) {
- return false;
- }
- if (len < _getMinMessageLen(message)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return false;
- }
- return true;
-}
-
-void Protocol::_LmeCallback(void *param, void *buffer, unsigned int len, int *status)
-{
- Protocol *prot = (Protocol *)param;
-
- if (prot->oldProtocolMode) {
- prot->_LmeReceiveCompat((char *)buffer, len, status);
- } else {
- prot->_LmeReceive(buffer, len, status);
- }
-}
-
-void Protocol::_LmeReceive(void *buffer, unsigned int len, int *status)
-{
- LMEMessage *message = (LMEMessage *)buffer;
- *status = 0;
-
- if (!_checkMessageAndProtocol(message, len)) {
- return;
- }
-
- switch (message->MessageType) {
- case APF_DISCONNECT:
- {
- PRINT("LME requested to disconnect with reason code 0x%08x\n",
- ((LMEDisconnectMessage *)message)->ReasonCode);
- Deinit();
- return;
- }
- break;
-
- case APF_SERVICE_REQUEST:
- {
- LMEServiceRequestMessage *sRMsg =
- (LMEServiceRequestMessage *)message;
-
- if ((sRMsg->ServiceName.compare(APF_SERVICE_AUTH) == 0) ||
- (sRMsg->ServiceName.compare(APF_SERVICE_PFWD) == 0)) {
-
- _lme.ServiceAccept(sRMsg->ServiceName);
- PRINT("Accepting service: %s\n",
- sRMsg->ServiceName.c_str());
- if (sRMsg->ServiceName.compare(APF_SERVICE_PFWD) == 0) {
- Lock l(_versionLock);
- _pfwdService = STARTED;
- }
- } else {
- PRINT("Requesting to disconnect from LME with reason code 0x%08x\n",
- APF_DISCONNECT_SERVICE_NOT_AVAILABLE);
- _lme.Disconnect(APF_DISCONNECT_SERVICE_NOT_AVAILABLE);
- Deinit();
- return;
- }
- }
- break;
-
- case APF_USERAUTH_REQUEST:
- {
- PRINT("Sending Userauth success message\n");
- _lme.UserAuthSuccess();
- }
- break;
-
- case APF_PROTOCOLVERSION:
- _apfProtocolVersion((LMEProtocolVersionMessage *)message);
- break;
-
- case APF_GLOBAL_REQUEST:
- _apfGlobalRequest((LMEGlobalRequestMessage *)message, len, status);
- break;
-
- case APF_CHANNEL_OPEN:
- _apfChannelOpen((LMEChannelOpenRequestMessage *)message, status);
- break;
-
- case APF_CHANNEL_OPEN_CONFIRMATION:
- {
- LMEChannelOpenReplaySuccessMessage *chOpenSuccMsg =
- (LMEChannelOpenReplaySuccessMessage *)message;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chOpenSuccMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- it->second->SetStatus(Channel::OPEN);
- it->second->SetRecipientChannel(chOpenSuccMsg->SenderChannel);
- it->second->AddBytesTxWindow(chOpenSuccMsg->InitialWindow);
- }
-
- _signalSelect();
- }
- break;
-
- case APF_CHANNEL_OPEN_FAILURE:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelOFail((LMEChannelOpenReplayFailureMessage *)message);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_CLOSE:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelClose((LMEChannelCloseMessage *)message);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_DATA:
- {
- PortForwardRequest *clPFwdReq =
- _apfChannelData((LMEChannelDataMessage *)message, status);
- if (clPFwdReq != NULL) {
- Lock l(_portsLock);
- _closePortForwardRequest(clPFwdReq);
- }
- }
- break;
-
- case APF_CHANNEL_WINDOW_ADJUST:
- {
- LMEChannelWindowAdjustMessage *channelWindowMessage = (LMEChannelWindowAdjustMessage *)message;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(channelWindowMessage->RecipientChannel);
- if (it != _openChannels.end()) {
- it->second->AddBytesTxWindow(channelWindowMessage->BytesToAdd);
- _signalSelect();
- }
- }
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- break;
- }
-}
-
-unsigned int Protocol::_getMinGlobalMsgLen(LMEGlobalRequestMessage *globalMessage)
-{
- switch (globalMessage->RequestType) {
- case LMEGlobalRequestMessage::TCP_FORWARD_REQUEST:
- return sizeof(LMETcpForwardRequestMessage);
- break;
- case LMEGlobalRequestMessage::TCP_FORWARD_CANCEL_REQUEST:
- return sizeof(LMETcpForwardCancelRequestMessage);
- break;
- case LMEGlobalRequestMessage::UDP_SEND_TO:
- return sizeof(LMEUdpSendToMessage);
- break;
- default:
- return 0;
- }
- return 0;
-}
-
-void Protocol::_apfGlobalRequest(LMEGlobalRequestMessage *globalMessage,
- unsigned int len, int *status)
-{
- PRINT("Global Request type 0x%02x\n", globalMessage->RequestType);
-
- if (len < _getMinGlobalMsgLen(globalMessage)) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return;
- }
-
- switch (globalMessage->RequestType) {
- case LMEGlobalRequestMessage::TCP_FORWARD_REQUEST:
- _apfTcpForwardRequest((LMETcpForwardRequestMessage *)globalMessage, status);
- break;
-
- case LMEGlobalRequestMessage::TCP_FORWARD_CANCEL_REQUEST:
- _apfTcpForwardCancel((LMETcpForwardCancelRequestMessage *)globalMessage);
- break;
-
- case LMEGlobalRequestMessage::UDP_SEND_TO:
- _aptSendUdp((LMEUdpSendToMessage *)globalMessage, status);
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- break;
- }
-}
-
-void Protocol::_apfTcpForwardRequest(LMETcpForwardRequestMessage *tcpFwdReqMsg, int *status)
-{
- IsConnectionPermittedCallback cb = NULL;
- bool failure = false;
-
-#ifdef _REMOTE_SUPPORT
- if (tcpFwdReqMsg->Address.compare("0.0.0.0") == 0) {
- cb = _isRemoteCallback;
- }
- else
-#endif
- {
- cb = _isLocalCallback;
- }
-
- {
- Lock l(_portsLock);
- SOCKET serverSocket = INVALID_SOCKET;
- listenPortSet::iterator lpi;
-
- if (_checkListen(tcpFwdReqMsg->Address, tcpFwdReqMsg->Port, serverSocket)) {
- *status = 1;
- // Log in Event Log
- TCHAR message[1024];
- _stprintf_s(message, 1024,
- TEXT("LMS Service already accepted a request at %s:%d\n"),
- tcpFwdReqMsg->Address.c_str(),
- tcpFwdReqMsg->Port);
- _eventLog(_eventLogParam, message, EVENTLOG_ERROR_TYPE);
- PRINT(message);
- // Send Failure replay to LME
- _lme.TcpForwardReplyFailure();
- return;
- }
-
- lpi = _listenFailReported.find(tcpFwdReqMsg->Port);
-
- if (serverSocket == INVALID_SOCKET) {
- int error;
- serverSocket = _listenPort(tcpFwdReqMsg->Port, error);
- if (serverSocket == INVALID_SOCKET) {
- *status = 1;
- // Log in Event Log
- TCHAR message[1024];
- _stprintf_s(message, 1024,
- TEXT("LMS Service cannot listen at port %d.\n"),
- tcpFwdReqMsg->Port);
- if (lpi == _listenFailReported.end()) {
- _eventLog(_eventLogParam, message, EVENTLOG_ERROR_TYPE);
- _listenFailReported.insert(tcpFwdReqMsg->Port);
- }
- PRINT(message);
- // Send Failure replay to LME
- _lme.TcpForwardReplyFailure();
- failure = true;
- }
- }
-
- if (failure != true) {
- PRINT("Listening at port %d at %s interface.\n",
- tcpFwdReqMsg->Port,
- ((cb == _isLocalCallback) ? "local" : "remote"));
-
- PortForwardRequest *portForwardRequest =
- new PortForwardRequest(tcpFwdReqMsg->Address,
- tcpFwdReqMsg->Port,
- serverSocket, cb, (cb == _isLocalCallback));
-
- _openPorts[tcpFwdReqMsg->Port].push_back(portForwardRequest);
-
- // Send Success replay to LME
- _lme.TcpForwardReplySuccess(tcpFwdReqMsg->Port);
-
- portForwardRequest->SetStatus(
- (cb == _isLocalCallback) ?
- PortForwardRequest::LISTENING :
- PortForwardRequest::PENDING_REQUEST);
- if (lpi != _listenFailReported.end()) {
- _listenFailReported.erase(lpi);
- }
-
- _signalSelect();
- }
- }
-
- if (failure == true) {
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_ERROR);
- Deinit();
- return;
- }
-
- if (cb == _isLocalCallback) {
- if (_listenFailReported.empty()) {
- _updateIPFQDN(tcpFwdReqMsg->Address.c_str());
- }
- }
-#ifdef _REMOTE_SUPPORT
- else {
- _checkRemoteSupport(true);
- }
-#endif
-}
-
-void Protocol::_apfTcpForwardCancel(LMETcpForwardCancelRequestMessage *tcpFwdCnclMsg)
-{
- bool found = false;
- Lock l(_portsLock);
-
- PortMap::iterator it = _openPorts.find(tcpFwdCnclMsg->Port);
- if (it == _openPorts.end()) {
- PRINT("Previous request on address %s and port %d doesn't exist.\n",
- tcpFwdCnclMsg->Address.c_str(), tcpFwdCnclMsg->Port);
- _lme.TcpForwardCancelReplyFailure();
- return;
- }
-
- PortForwardRequestList::iterator it2 = it->second.begin();
- for (; it2 != it->second.end(); it2++) {
- if (((*it2)->GetBindedAddress().compare(tcpFwdCnclMsg->Address) == 0) &&
- //((*it2)->GetPort() == tcpFwdCnclMsg->Port)) {
- ((*it2)->GetStatus() != PortForwardRequest::NOT_ACTIVE)) {
- found = true;
- break;
- }
- }
-
- if (found) {
- (*it2)->SetStatus(PortForwardRequest::NOT_ACTIVE);
- if ((*it2)->GetChannelCount() == 0) {
- _closePortForwardRequest(*it2);
- }
- _lme.TcpForwardCancelReplySuccess();
- } else {
- PRINT("Previous request on address %s and port %d doesn't exist.\n",
- tcpFwdCnclMsg->Address.c_str(), tcpFwdCnclMsg->Port);
- _lme.TcpForwardCancelReplyFailure();
- }
-}
-
-void Protocol::_aptSendUdp(LMEUdpSendToMessage *udpSendToMessage, int *status)
-{
- int error = 0;
-
- SOCKET s = ATNetworkTool::Connect(udpSendToMessage->Address.c_str(),
- udpSendToMessage->Port, error,
- PF_INET, SOCK_DGRAM);
- if (s == INVALID_SOCKET) {
- *status = 1;
- PRINT("Unable to send UDP data.\n");
- return;
- }
-
- int count = _send(s, (char *)udpSendToMessage->Data, udpSendToMessage->DataLength, error);
- PRINT("Sent UDP data: %d bytes of %d.\n", count, udpSendToMessage->DataLength);
-
- ATNetworkTool::CloseSocket(s);
-}
-
-void Protocol::_apfProtocolVersion(LMEProtocolVersionMessage *verMsg)
-{
- Lock l(_versionLock);
-
- switch (_handshakingStatus) {
- case AGREED:
- case NOT_INITIATED:
- _lme.ProtocolVersion(MAX_PROT_VERSION);
- case INITIATED:
- if (*verMsg < MIN_PROT_VERSION) {
- PRINT("Version %d.%d is not supported.\n",
- verMsg->MajorVersion, verMsg->MinorVersion);
- _lme.Disconnect(APF_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED);
- Deinit();
- return;
- }
- if (*verMsg > MAX_PROT_VERSION) {
- _AmtProtVersion = MAX_PROT_VERSION;
- } else {
- _AmtProtVersion = (*verMsg);
- }
- _handshakingStatus = AGREED;
- break;
-
- default:
- _lme.Disconnect(APF_DISCONNECT_BY_APPLICATION);
- Deinit();
- break;
- }
-}
-
-void Protocol::_apfChannelOpen(LMEChannelOpenRequestMessage *chOpenMsg, int *status)
-{
- int error = 0;
-
- PRINT("Got channel request from AMT. "
- " Recipient channel %d for address %s, port %d.\n",
- chOpenMsg->SenderChannel,
- chOpenMsg->Address.c_str(), chOpenMsg->Port);
-
- SOCKET s = ATNetworkTool::Connect(chOpenMsg->Address.c_str(),
- chOpenMsg->Port, error, PF_INET);
- if (s == INVALID_SOCKET) {
- *status = 1;
- PRINT("Unable to open direct channel to address %s.\n",
- chOpenMsg->Address.c_str());
- return;
- }
-
- ATNetworkTool::SetNonBlocking(s);
-
- Channel *c = new Channel(NULL, s);
- c->AddBytesTxWindow(chOpenMsg->InitialWindow);
- c->SetRecipientChannel(chOpenMsg->SenderChannel);
- c->SetStatus(Channel::OPEN);
-
- {
- Lock l(_channelsLock);
- _openChannels[c->GetSenderChannel()] = c;
- _lme.ChannelOpenReplaySuccess(c->GetRecipientChannel(), c->GetSenderChannel());
- }
-
- _signalSelect();
-}
-
-PortForwardRequest *Protocol::_closeMChannel(Channel *c)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- ATNetworkTool::CloseSocket(c->GetSocket());
- PortForwardRequest *p = c->GetPortForwardRequest();
- if ((p != NULL) && (p->DecreaseChannelCount() == 0)) {
- clPFwdReq = p;
- }
- delete c;
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelOFail(LMEChannelOpenReplayFailureMessage *chFailMsg)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chFailMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- clPFwdReq = _closeMChannel(it->second);
- _openChannels.erase(it);
- PRINT("Channel open request was refused. Reason code: 0x%02x reason.\n",
- chFailMsg->ReasonCode);
- }
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelClose(LMEChannelCloseMessage *chClMsg)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chClMsg->RecipientChannel);
- if (it != _openChannels.end()) {
- Channel *c = it->second;
- switch(c->GetStatus()) {
- case Channel::OPEN:
- c->SetStatus(Channel::CLOSED);
- _lme.ChannelClose(c->GetRecipientChannel());
- PRINT("Channel %d was closed by AMT.\n", c->GetSenderChannel());
- break;
-
- case Channel::WAITING_CLOSE:
- PRINT("Received reply by AMT on closing channel %d.\n", c->GetSenderChannel());
- break;
-
- case Channel::CLOSED:
- case Channel::NOT_OPENED:
- break;
- }
-
- clPFwdReq = _closeMChannel(c);
- _openChannels.erase(it);
- }
-
- return clPFwdReq;
-}
-
-PortForwardRequest *Protocol::_apfChannelData(LMEChannelDataMessage *chDMsg, int *status)
-{
- PortForwardRequest *clPFwdReq = NULL;
-
- do {
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(chDMsg->RecipientChannel);
- if (it == _openChannels.end()) {
- break;
- }
-
- if ((it->second->GetStatus() != Channel::OPEN) &&
- (it->second->GetStatus() != Channel::WAITING_CLOSE)) {
- break;
- }
-
- if (it->second->GetRxWindow() < chDMsg->DataLength) {
- break;
- }
-
- int senderr = 0;
- int count = _send(it->second->GetSocket(), (char *)chDMsg->Data,
- chDMsg->DataLength, senderr);
- PRINT("Sent %d bytes of %d from AMT to channel %d with socket %d.\n",
- count, chDMsg->DataLength, chDMsg->RecipientChannel,
- it->second->GetSocket());
-
- if ((count == -1) && (senderr == EPIPE)) {
- *status = 1;
- clPFwdReq = _closeMChannel(it->second);
- _openChannels.erase(it);
- PRINT("Channel send data request was refused. Broken pipe.\n");
- break;
- }
- //it->second->AddBytesRxWindow(-count);
- //if (it->second->GetRxWindow() < Channel::LMS_WINDOW_SIZE / 2) {
- _lme.ChannelWindowAdjust(it->second->GetRecipientChannel(), chDMsg->DataLength);
- //Channel::LMS_WINDOW_SIZE - it->second->GetRxWindow());
- //}
- } while (0);
-
- return clPFwdReq;
-}
-
-#ifdef _REMOTE_SUPPORT
-
-bool Protocol::_compareDNSSuffix(std::string AMTDNSSuffix, std::string suffix)
-{
- if (AMTDNSSuffix.size() > suffix.size()) {
- return false;
- }
-
- if ((AMTDNSSuffix.size() < suffix.size()) &&
- (suffix[suffix.size()-AMTDNSSuffix.size()-1] != '.')) {
- return false;
- }
-
- if (strnicmp(suffix.c_str() + suffix.size()-AMTDNSSuffix.size(),
- AMTDNSSuffix.c_str(),
- AMTDNSSuffix.size()) == 0) {
- return true;
- }
-
- return false;
-}
-
-bool Protocol::_checkRemoteSupport(bool requestDnsFromAmt)
-{
- if (requestDnsFromAmt) {
- std::list<std::string> amtDnsSuffixes;
-
- AMT_STATUS status = _cfg.RequestEntDNSSuffixList(amtDnsSuffixes);
-
- if (status != AMT_STATUS_SUCCESS) {
- PRINT("Remote access is disabled - AMT is not configured [%x]\n", status);
- return false;
- }
-
- _AMTDNSLock.acquire();
- _AMTDNSSuffixes.clear();
- _AMTDNSSuffixes.assign(amtDnsSuffixes.begin(), amtDnsSuffixes.end());
- _AMTDNSLock.release();
-
- amtDnsSuffixes.clear();
- }
-
- ATDomainMap domains;
- int error = 0;
- ATNetworkTool::GetLocalNetDomains(domains, error, PF_INET);
- _updateEnterpriseAccessStatus(domains);
-
- return true;
-}
-
-void Protocol::_updateEnterpriseAccessStatus(const ATDomainMap &localDNSSuffixes)
-{
- _AMTDNSLock.acquire();
-
- std::list<std::string>::iterator remIt;
- std::list<std::string>::iterator startIt = _AMTDNSSuffixes.begin();
- std::list<std::string>::iterator endIt = _AMTDNSSuffixes.end();
- ATDomainMap::const_iterator locIt;
-
- bool access = false;
- ATAddress localIp;
-
- for (locIt = localDNSSuffixes.begin(); locIt != localDNSSuffixes.end(); locIt++) {
- remIt = find_if(startIt, endIt, bind2nd(ptr_fun(_compareDNSSuffix), locIt->second));
- if (remIt != _AMTDNSSuffixes.end()) {
- access = true;
- localIp = locIt->first;
- break;
- }
- }
-
- _AMTDNSLock.release();
-
- bool sendEntAccessMessage = true;
- if (access) {
- Lock l(_portsLock);
- for (PortMap::iterator it = _openPorts.begin(); it != _openPorts.end(); it++) {
- for (PortForwardRequestList::iterator it2 = it->second.begin();
- it2 != it->second.end(); it2++) {
-
- if ((*it2)->GetStatus() == PortForwardRequest::PENDING_REQUEST) {
- (*it2)->SetStatus(PortForwardRequest::LISTENING);
- sendEntAccessMessage = false;
- break; // Assuming that there is a such request one per port
- }
- }
- }
-
- _signalSelect();
- }
-
- if (sendEntAccessMessage == false) {
- return;
- }
-
- AMT_STATUS status = _cfg.SendEnterpriseAccess(access, localIp);
-
- Lock l(_remoteAccessLock);
- _remoteAccessEnabled = (status == AMT_STATUS_SUCCESS);
- switch (status) {
- case AMT_STATUS_SUCCESS:
- PRINT("Remote access is allowed.\n");
- break;
- case AMT_STATUS_REMOTE_ACCESS_NOT_GRANTED:
- PRINT("Remote access is denied because AMT is directly connected "
- "to enterprise network.\n");
- break;
- case AMT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED:
- PRINT("Remote access is disabled.\n");
- break;
- default:
- PRINT("Remote access is disabled.\n");
- break;
- }
-
- //if (_remoteAccessEnabled) {
- // Lock l(_portsLock);
- // for (PortMap::iterator it = _openPorts.begin(); it != _openPorts.end(); it++) {
- // for (PortForwardRequestList::iterator it2 = it->second.begin();
- // it2 != it->second.end(); it2++) {
-
- // if ((*it2)->GetStatus() == PortForwardRequest::PENDING_REQUEST) {
- // (*it2)->SetStatus(PortForwardRequest::LISTENING);
- // break; // Assuming that there is a such request one per port
- // }
- // }
- // }
-
- // _signalSelect();
- //}
-
-}
-
-#endif
-
-int Protocol::_isLocalCallback(void *const param, SOCKET s)
-{
- int error = 0;
-
- return ((1 == ATNetworkTool::IsSockPeerLocal(s, error, PF_INET)) ? 1 : -1);
-}
-
-#ifdef _REMOTE_SUPPORT
-
-int Protocol::_isRemoteCallback(void *const param, SOCKET s)
-{
- Protocol *prot = (Protocol *)param;
-
- return prot->_isRemote(s);
-}
-
-int Protocol::_isRemote(SOCKET s) const
-{
- int result = 0;
- int error = 0;
- int ret;
- std::string dnsSuffix;
-
- ret = ATNetworkTool::GetSockDomain(s, dnsSuffix, error);
- if (ret != 1) {
- return ret;
- }
-
- Lock l(_remoteAccessLock);
-
- if (_remoteAccessEnabled) {
-
- _AMTDNSLock.acquire();
-
- std::list<std::string>::const_iterator it = _AMTDNSSuffixes.begin();
- for (; it != _AMTDNSSuffixes.end(); it++) {
- if (_compareDNSSuffix(*it, dnsSuffix)) {
- result = 1;
- break;
- }
- }
-
- _AMTDNSLock.release();
- }
-
- return result;
-}
-#endif
-
-int Protocol::_updateIPFQDN(const char *fqdn)
-{
- if (strcmp(fqdn, _AMTFQDN) != 0) {
- char localName[FQDN_MAX_SIZE] = "\0";
- int res = gethostname(localName, sizeof(localName));
-
- // If AMT FQDN is equal to local FQDN than we don't do anything
- if ((res == -1) || (strcmp(fqdn, localName) != 0)) {
- if (_handleFQDNChange(fqdn) < 0) {
- ERROR("Error: failed to update FQDN info\n");
- return -1;
- }
- } else {
- if (_handleFQDNChange("") < 0) {
- ERROR("Error: failed to update FQDN info\n");
- return -1;
- }
- }
- }
-
- memcpy(_AMTFQDN, fqdn, sizeof(_AMTFQDN));
-
- PRINT("Got FQDN: %s\n", _AMTFQDN);
-
- return 0;
-}
-
-
-char *Protocol::_getErrMsg(DWORD err)
-{
- static char buffer[1024];
-
-#if defined(__sun) || defined(_LINUX)
- strerror_r(err, buffer, sizeof(buffer) - 1);
-#else
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- err,
- 0,
- buffer,
- sizeof(buffer) - 1,
- 0);
-#endif // __sun || _LINUX
-
- return buffer;
-}
-
-
-int Protocol::_handleFQDNChange(const char *fqdn)
-{
- const char *hostFile = "hosts";
- const char *tmpFile = "hosts-lms.tmp";
- bool hasFqdn = false;
-#define LMS_MAX_FILENAME_LEN 1024
- char inFileName[LMS_MAX_FILENAME_LEN] = "";
- char oldFqdn[FQDN_MAX_SIZE + 1];
- char outFileName[LMS_MAX_FILENAME_LEN] = "";
- char host[FQDN_MAX_SIZE + 1];
-#define LMS_MAX_LINE_LEN 1023
- char line[LMS_MAX_LINE_LEN + 1];
-#define LMS_LINE_SIG_FIRST_WORDS "# LMS GENERATED "
-#define LMS_LINE_SIG_LAST_WORD "LINE"
-#define LMS_LINE_SIG_LAST_WORD_LEN 4
-#define LMS_LINE_SIG LMS_LINE_SIG_FIRST_WORDS LMS_LINE_SIG_LAST_WORD
-#define lmsstr(s) lmsname(s)
-#define lmsname(s) #s
-#define LMS_LINE_FORMAT "127.0.0.1 %s %s " LMS_LINE_SIG
-#define LMS_LINE_SCAN_FORMAT "127.0.0.1 %" lmsstr(FQDN_MAX_SIZE) "s %" lmsstr(FQDN_MAX_SIZE) "s " LMS_LINE_SIG_FIRST_WORDS "%" lmsstr(LMS_LINE_SIG_LAST_WORD_LEN) "c"
- char tmpsige[LMS_LINE_SIG_LAST_WORD_LEN];
-
-#if defined(__sun) || defined(_LINUX)
-
- const char *dir = "/etc/";
-
-#else
-
- char *sysDrive;
- const char *dir = "\\system32\\drivers\\etc\\";
-
- sysDrive = getenv("SystemRoot");
- if (NULL == sysDrive) {
- return -1;
- }
-
- // sanity check before string copying
- if (LMS_MAX_FILENAME_LEN < (strnlen(sysDrive, LMS_MAX_FILENAME_LEN)
- + strnlen(dir, LMS_MAX_FILENAME_LEN)
- + strnlen(hostFile, LMS_MAX_FILENAME_LEN) + 1)) {
- return -1;
- }
- // sanity check before string copying
- if (LMS_MAX_FILENAME_LEN < (strnlen(sysDrive, LMS_MAX_FILENAME_LEN)
- + strnlen(dir, LMS_MAX_FILENAME_LEN)
- + strnlen(tmpFile, LMS_MAX_FILENAME_LEN) + 1)) {
- return -1;
- }
-
- strncpy(inFileName, sysDrive, LMS_MAX_FILENAME_LEN - 1);
- strncpy(outFileName, sysDrive, LMS_MAX_FILENAME_LEN - 1);
-
-#endif // __sun || _LINUX
-
- strncat(inFileName, dir, LMS_MAX_FILENAME_LEN - 1);
- strncat(outFileName, dir, LMS_MAX_FILENAME_LEN - 1);
- strncat(inFileName, hostFile, LMS_MAX_FILENAME_LEN - 1);
- strncat(outFileName, tmpFile, LMS_MAX_FILENAME_LEN - 1);
-
- FILE *ifp = fopen(inFileName, "r");
- if (NULL == ifp) {
- _eventLog(_eventLogParam, TEXT("Error: Can't open hosts file"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
-
- FILE *ofp = fopen(outFileName, "w");
- if (NULL == ofp) {
- _eventLog(_eventLogParam, TEXT("Error: Can't create temporary hosts file"), EVENTLOG_ERROR_TYPE);
- fclose(ifp);
- return -1;
- }
-
- // First create a copy of the hosts file, without lines that were
- // previously added by the LMS.
- // Go over each line and copy it to the tmp file.
- while (fgets(line, sizeof(line), ifp)) {
- // don't copy the line if it was generated by the LMS
- memset(oldFqdn, 0, sizeof(oldFqdn));
- memset(tmpsige, 0, sizeof(tmpsige));
- if (0 == (
- (3 == sscanf(line, LMS_LINE_SCAN_FORMAT, oldFqdn, host, tmpsige))
- ? strncmp(tmpsige, LMS_LINE_SIG_LAST_WORD, LMS_LINE_SIG_LAST_WORD_LEN)
- : (-2))
- ) {
- if (0 == strncmp((char *)fqdn, oldFqdn, FQDN_MAX_SIZE)) {
- // copy the old LMS line too, since it's up to date
- fprintf(ofp, "%s", line);
- hasFqdn = true;
- }
- continue;
- }
-
- fprintf(ofp, "%s", line);
-
- while ((LMS_MAX_LINE_LEN == strnlen(line, LMS_MAX_LINE_LEN))
- && ('\n' != line[LMS_MAX_LINE_LEN - 1])
- && (fgets(line, sizeof(line), ifp))) {
- fprintf(ofp, "%s", line);
- }
- }
-
- if (hasFqdn) {
- fclose(ofp);
- fclose(ifp);
- unlink(outFileName);
- return 0;
- }
-
- // If the original hosts file does not end with a new line character,
- // add a new line at the end of the new file before adding our line.
- fseek(ifp, -1, SEEK_END);
- char lastChar = fgetc(ifp);
- if ('\n' != lastChar) {
- fprintf(ofp, "\n");
- }
-
- memset(host, 0, FQDN_MAX_SIZE + 1);
- strncpy(host, fqdn, FQDN_MAX_SIZE);
- char *lmsdot = strchr(host, '.');
- if (NULL != lmsdot) {
- lmsdot[0] = '\0';
- }
-
- if ((fqdn != NULL) && (fqdn[0] != 0)) {
- // Add the specified FQDN to the end of the tmp file
- fprintf(ofp, LMS_LINE_FORMAT "\n", fqdn, host);
- }
-
- fclose(ofp);
- fclose(ifp);
-
- if (0 != std::rename(outFileName, inFileName)) {
- std::string tmp2FileName = std::string(inFileName) + ".~tmp";
- std::ifstream mfile(inFileName, std::ios_base::in);
- if (!mfile.is_open()) {
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [1]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- std::ofstream wfile(tmp2FileName.c_str(), std::ios_base::out | std::ios_base::trunc);
- if (!wfile.is_open()) {
- mfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [2]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- wfile << mfile.rdbuf();
- if (wfile.bad()) {
- mfile.close();
- wfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [3]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- mfile.close();
- wfile.close();
- std::ifstream sfile(outFileName, std::ios_base::in);
- if (!sfile.is_open()) {
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [4]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- std::ofstream dfile(inFileName, std::ios_base::out | std::ios_base::trunc);
- if (!dfile.is_open()) {
- sfile.close();
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [5]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- dfile << sfile.rdbuf();
- if (dfile.bad()) {
- sfile.close();
- dfile.close();
- unlink(inFileName);
- if (0 != std::rename(outFileName, inFileName)) {
- std::rename(tmp2FileName.c_str(), inFileName);
- _eventLog(_eventLogParam, TEXT("Error: Can't update hosts file [6]"), EVENTLOG_ERROR_TYPE);
- return -1;
- }
- }
- sfile.close();
- dfile.close();
- }
-
- _eventLog(_eventLogParam, TEXT("hosts file updated"), EVENTLOG_INFORMATION_TYPE);
-
- return 0;
-}
-
-ssize_t Protocol::_send(int s, const void *buf, size_t len, int &senderr)
-{
- ssize_t result;
-
-#if defined(_LINUX)
- if (-1 == (result = send(s, buf, len, MSG_NOSIGNAL))) {
- senderr = errno;
- }
-#elif defined(__sun)
- if (-1 == (result = send(s, buf, len, 0))) {
- senderr = errno;
- }
-#else
- result = send(s, buf, len);
-#endif // _LINUX
-
- return result;
-}
-
diff --git a/usr/src/cmd/lms/Protocol.h b/usr/src/cmd/lms/Protocol.h
deleted file mode 100644
index b681888248..0000000000
--- a/usr/src/cmd/lms/Protocol.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _PROTOCOL_H_
-#define _PROTOCOL_H_
-
-#include <map>
-#include <vector>
-#include <set>
-#include <string>
-#include "types.h"
-#include "LMS_if.h"
-#include "LMEConnection.h"
-#include "PortForwardRequest.h"
-#include "Channel.h"
-#include "Semaphore.h"
-
-#if defined(__sun) || defined(_LINUX)
-
-#define SOCKET int
-#define INVALID_SOCKET (SOCKET)(~0)
-#define SOCKET_ERROR (-1)
-#else
-#include <windows.h>
-#endif // __sun || _LINUX
-
-#ifdef _REMOTE_SUPPORT
-#include "ConfigConnection.h"
-#endif
-
-#define FQDN_MAX_SIZE 256
-
-typedef void (*EventLogCallback)(void *param, LPCTSTR message, WORD eventType);
-
-class Protocol
-{
-public:
-
- static const LMEProtocolVersionMessage MIN_PROT_VERSION;
- static const LMEProtocolVersionMessage MAX_PROT_VERSION;
-
- enum SOCKET_STATUS {
- ACTIVE = 0,
- NOT_CREATED,
- LINGER_ERROR,
- NOT_BINDED,
- NOT_EXCLUSIVE_ADDRESS,
- NOT_LISTENED
- };
-
- Protocol();
- ~Protocol();
-
- bool CreateSockets();
- void DestroySockets();
- bool SocketsCreated() { return _sockets_active; }
- bool IsDeInitialized();
- bool IsInitialized();
- bool Init(EventLogCallback cb, void *param);
- int Select();
- void Deinit();
- void DeinitFull();
-
- bool oldProtocolMode;
-
-private:
- static void _LmeCallback(void *param, void *buffer, unsigned int len, int *status);
- static int _isLocalCallback(void *const param, SOCKET s);
-#ifdef _REMOTE_SUPPORT
- static int _isRemoteCallback(void *const param, SOCKET s);
-#endif
- static char *_getErrMsg(DWORD err);
-
- bool _checkProtocolFlow(LMEMessage *message);
- unsigned int _getMinMessageLen(LMEMessage *message);
- unsigned int _getMinGlobalMsgLen(LMEGlobalRequestMessage *globalMessage);
- bool _checkMessageAndProtocol(LMEMessage *message, unsigned int len);
- void _closePortForwardRequest(PortForwardRequest *p);
- void _apfGlobalRequest(LMEGlobalRequestMessage *globalMessage, unsigned int len, int *status);
- void _apfTcpForwardRequest(LMETcpForwardRequestMessage *tcpFwdReqMsg, int *status);
- void _apfTcpForwardCancel(LMETcpForwardCancelRequestMessage *tcpFwdCnclMsg);
- void _aptSendUdp(LMEUdpSendToMessage *udpSendToMessage, int *status);
- void _apfProtocolVersion(LMEProtocolVersionMessage *verMsg);
- void _apfChannelOpen(LMEChannelOpenRequestMessage *chOpenMsg, int *status);
- PortForwardRequest *_closeMChannel(Channel *c);
- PortForwardRequest *_apfChannelOFail(LMEChannelOpenReplayFailureMessage *chFailMsg);
- PortForwardRequest *_apfChannelClose(LMEChannelCloseMessage *chClMsg);
- PortForwardRequest *_apfChannelData(LMEChannelDataMessage *chDMsg, int *status);
- void _LmeReceive(void *buffer, unsigned int len, int *status);
- void _LmeReceiveCompat(char *buffer, unsigned int len, int *status);
- void _signalSelect();
- bool _acceptConnection(SOCKET s, unsigned int port);
- int _rxFromSocket(SOCKET s);
- int _handleFQDNChange(const char *fqdn);
- int _updateIPFQDN(const char *fqdn);
-#ifdef _REMOTE_SUPPORT
- static bool _compareDNSSuffix(std::string AMTDNSSuffix, std::string suffix);
- int _isRemote(SOCKET s) const;
- bool _checkRemoteSupport(bool requestDnsFromAmt = false);
- void _updateEnterpriseAccessStatus(const ATDomainMap &localDNSSuffixes);
-#endif
- ssize_t _send(int s, const void *buf, size_t len, int &senderr);
- bool _checkListen(std::string address, in_port_t port, int &socket);
- int _listenPort(in_port_t port, int &error);
- bool _localListen(in_port_t port);
- Channel *_getSockOpenChannel(SOCKET s);
-
-
- struct Connection {
- SOCKET s;
- };
-
- typedef std::vector<PortForwardRequest *> PortForwardRequestList;
- typedef std::map<unsigned int, PortForwardRequestList> PortMap;
- typedef std::map<unsigned int, Channel *> ChannelMap;
-
- LMEConnection _lme;
- char *_rxSocketBuffer;
- unsigned int _rxSocketBufferSize;
-#ifdef _REMOTE_SUPPORT
- ConfigConnection _cfg;
-#endif
- SOCKET _serverSignalSocket;
- SOCKET _clientSignalSocket; // Used to notify Select() to check new available channels
- bool _sockets_active;
- PortMap _openPorts;
- ChannelMap _openChannels;
- Semaphore _portsLock;
- Semaphore _channelsLock;
-#ifdef _REMOTE_SUPPORT
- std::list<std::string> _AMTDNSSuffixes;
- mutable Semaphore _AMTDNSLock;
- bool _remoteAccessEnabled;
- mutable Semaphore _remoteAccessLock;
-#endif
-
- enum VERSION_HANDSHAKING {
- NOT_INITIATED,
- INITIATED,
- AGREED
- };
-
- enum SERVICE_STATUS {
- NOT_STARTED,
- STARTED
- };
-
- VERSION_HANDSHAKING _handshakingStatus;
- SERVICE_STATUS _pfwdService;
- LMEProtocolVersionMessage _AmtProtVersion;
- Semaphore _versionLock;
-
- char _AMTFQDN[FQDN_MAX_SIZE];
- EventLogCallback _eventLog;
- void *_eventLogParam;
-
- bool _deinitReq;
- Semaphore _deinitLock;
-
- typedef std::set<unsigned int> listenPortSet;
- listenPortSet _listenFailReported;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/ProtocolCompat.cpp b/usr/src/cmd/lms/ProtocolCompat.cpp
deleted file mode 100644
index 7264bf100e..0000000000
--- a/usr/src/cmd/lms/ProtocolCompat.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if defined(__sun) || defined(_LINUX)
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#else
-#include <winsock2.h>
-#endif // __sun || _LINUX
-
-#include <cerrno>
-#include "Protocol.h"
-#include "LMS_if_compat.h"
-#include "Lock.h"
-#include "ATNetworkTool.h"
-
-void Protocol::_LmeReceiveCompat(char *buffer, unsigned int len, int *status)
-{
- int error = 0;
-
- PRINT("[Compat]HECI receive %d bytes (msg type 0x%02x)\n", len, buffer[0]);
- *status = 0;
-
- switch (buffer[0]) {
- case LMS_MESSAGE_TYPE_OPEN_CONNECTION_EX:
- {
- SOCKET s_new = INVALID_SOCKET;
- LMS_OPEN_CONNECTION_EX_MESSAGE *msg =
- (LMS_OPEN_CONNECTION_EX_MESSAGE *)buffer;
-
- int type;
- switch (msg->Protocol) {
- case LMS_PROTOCOL_TYPE_UDP_IPV4:
- type = SOCK_DGRAM;
- break;
- case LMS_PROTOCOL_TYPE_TCP_IPV4:
- default:
- type = SOCK_STREAM;
- break;
- }
-
- if ((msg->Flags & HOSTNAME_BIT) != 0) {
- PRINT("[Compat]Got client connection request %d for host %s, port %d\n",
- msg->ConnectionId,
- msg->Host,
- ntohs(msg->HostPort));
-
- s_new = ATNetworkTool::Connect(
- (const char *)msg->Host,
- ntohs(msg->HostPort),
- error, PF_INET, type);
- } else {
- PRINT("[Compat]Got client connection request %d for IP %s, port %d\n",
- msg->ConnectionId,
- inet_ntoa(*((struct in_addr *)msg->Host)),
- ntohs(msg->HostPort));
-
- s_new = ATNetworkTool::Connect(
- inet_ntoa(*((struct in_addr *)msg->Host)),
- ntohs(msg->HostPort),
- error, PF_INET, type);
- }
-
- if (s_new == INVALID_SOCKET) {
- *status = 1;
- break;
- }
-
- Channel *c = new Channel(NULL, s_new);
- c->SetRecipientChannel(msg->ConnectionId);
- c->SetStatus(Channel::OPEN);
- c->AddBytesTxWindow(1024);
- {
- Lock l(_channelsLock);
- _openChannels[msg->ConnectionId] = c;
- }
-
- _signalSelect();
- }
- break;
-
- case LMS_MESSAGE_TYPE_CLOSE_CONNECTION:
- {
- LMS_CLOSE_CONNECTION_MESSAGE *msg =
- (LMS_CLOSE_CONNECTION_MESSAGE *)buffer;
-
- PRINT("[Compat]received close connection msg from HECI for connection %d\n", msg->ConnectionId);
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(msg->ConnectionId);
- if (it != _openChannels.end()) {
- _closeMChannel(it->second);
- _openChannels.erase(it);
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_SEND_DATA:
- {
- LMS_SEND_DATA_MESSAGE *msg =
- (LMS_SEND_DATA_MESSAGE *)buffer;
-
- Lock l(_channelsLock);
-
- ChannelMap::iterator it = _openChannels.find(msg->ConnectionId);
- if (it != _openChannels.end()) {
- PRINT("[Compat]sending %d bytes from HECI connection %d to socket %d\n", ntohs(msg->DataLength), msg->ConnectionId, it->second->GetSocket());
- if (-1 == _send(it->second->GetSocket(), (char *)msg->Data, ntohs(msg->DataLength), error)) {
- if (EPIPE == error) {
- _closeMChannel(it->second);
- _openChannels.erase(it);
- *status = 1;
- }
- }
- }
- }
- break;
-
- case LMS_MESSAGE_TYPE_IP_FQDN:
- if (_updateIPFQDN((const char *)((LMS_IP_FQDN_MESSAGE *)buffer)->FQDN) != 0) {
- ERROR("[Compat]Error: failed to update IP/FQDN info\n");
- }
- break;
-
- default:
- *status = 1;
- break;
- }
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Event.h b/usr/src/cmd/lms/SyncLib/Include/Event.h
deleted file mode 100644
index 6c00153c48..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Event.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Event.h
-//
-// This file contains the definition of the Event class (for thread
-// synchronization)
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_EVENT_H
-#define _LAD_EVENT_H
-
-#ifndef WAIT_INFINITE
-#define WAIT_INFINITE 0xffffffff
-#endif
-
-class OSEvent;
-
-class Event
-{
-public:
- Event(bool manual = false);
- Event(const Event &rhs);
- ~Event();
-
- void set();
- void reset();
- bool wait(unsigned long msecs = WAIT_INFINITE);
- Event& operator=(const Event &rhs);
-
-private:
- OSEvent *_osEvent;
-};
-
-#endif //_LAD_EVENT_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Lock.h b/usr/src/cmd/lms/SyncLib/Include/Lock.h
deleted file mode 100644
index 4a59bd9ed1..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Lock.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Lock.h
-//
-// This file contains the definition and implementation of the Lock class
-// and the TryLock class
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_LOCK_H
-#define _LAD_LOCK_H
-#include "RWLock.h"
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-class Lock
-{
-public:
- Lock(Semaphore &sem) : _sem(&sem), _rw_lock(NULL)
- {
- _sem->acquire();
- }
-
- Lock(RWLock &rw_lock, RWLock::RWMode mode = RWLock::READ_ONLY) :
- _sem(NULL), _rw_lock(&rw_lock)
- {
- _rw_lock->acquire(mode);
- }
-
- ~Lock()
- {
- if (_sem) {
- _sem->release();
- }
- if (_rw_lock) {
- _rw_lock->release();
- }
-
- }
-
-private:
- Semaphore *_sem;
- RWLock *_rw_lock;
-};
-
-class TryLock
-{
-public:
- TryLock(Semaphore &sem, bool &is_locked) : _sem(&sem)
- {
- _locked = _sem->acquireTry();
- is_locked = _locked;
- }
-
- ~TryLock()
- {
- if (_locked) {
- _sem->release();
- }
- }
-
-private:
- bool _locked;
- Semaphore *_sem;
-};
-
-#endif //_LAD_LOCK_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/RWLock.h b/usr/src/cmd/lms/SyncLib/Include/RWLock.h
deleted file mode 100644
index be1f653dc2..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/RWLock.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _RW_LOCK_H_
-#define _RW_LOCK_H_
-
-#include "Semaphore.h"
-
-class RWLock
-{
-public:
- enum RWMode {
- READ_ONLY,
- READ_WRITE
- };
-
- RWLock();
- ~RWLock() {}
-
- void acquire(const RWMode mode_p = READ_ONLY);
- void release();
- void switch2RO();
-
-private:
- Semaphore _readSem;
- Semaphore _writeSem;
- Semaphore _countSem;
- unsigned int _counter;
-};
-
-#endif //_RW_LOCK_H_
diff --git a/usr/src/cmd/lms/SyncLib/Include/SPtr.h b/usr/src/cmd/lms/SyncLib/Include/SPtr.h
deleted file mode 100644
index f1d4405ddf..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/SPtr.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// SPtr.h
-//
-// This is a smart pointer class. It receives an initialized object in
-// the constructor, and maintains a reference count to this object. It
-// deletes the object only when the reference count reaches 0.
-//
-//////////////////////////////////////////////////////////////////////////
-
-#ifndef _SPTR_H_
-#define _SPTR_H_
-
-#include <memory>
-#include "Semaphore.h"
-
-template
-<class T>
-class SPtr
-{
-public:
- // constructor
- explicit SPtr(T *ptr_p = 0) :
- _ptr(ptr_p),
- _pref_count(new int(1)),
- _psem(new Semaphore(1)) {}
-
- // copy constructor
- template<class X>
- SPtr(const SPtr<X> &other_sptr_p)
- {
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- }
-
- SPtr(const SPtr &other_sptr_p)
- {
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- }
-
- // destructor
- ~SPtr()
- {
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- // delete pointer only on last destruction
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- _ptr = 0;
- } else {
- _psem->release();
- }
- }
-
- // operator=
- // if 'this' already points to an object, unreference it
- template<class X>
- SPtr &operator= (const SPtr<X> &other_sptr_p)
- {
- if ((void *)&other_sptr_p == this) {
- return *this;
- }
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- } else {
- _psem->release();
- }
- other_sptr_p.getSem()->acquire();
- _ptr = (T *)other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- return *this;
- }
-
- SPtr &operator=(const SPtr &other_sptr_p)
- {
- if (&other_sptr_p == this) {
- return *this;
- }
- _psem->acquire();
- if (--(*_pref_count) == 0) {
- delete _pref_count;
- delete _psem;
- if (_ptr) {
- delete _ptr;
- }
- } else {
- _psem->release();
- }
- other_sptr_p.getSem()->acquire();
- _ptr = other_sptr_p.get();
- _pref_count = other_sptr_p.getRefcnt();
- _psem = other_sptr_p.getSem();
- ++(*_pref_count);
- _psem->release();
- return *this;
- }
-
- // operator*
- T &operator*() const
- {
- return *_ptr;
- }
-
- // operator->
- T *operator->() const
- {
- return _ptr;
- }
-
- // get - return inner pointer
- T *get() const
- {
- return _ptr;
- }
-
- int *getRefcnt() const
- {
- return _pref_count;
- }
-
- Semaphore *getSem() const
- {
- return _psem;
- }
-
-private:
- // the pointer itself
- T *_ptr;
- // a pointer to the reference count
- int *_pref_count;
- Semaphore *_psem;
-} ;
-
-template
-<class T>
-inline bool operator==(const SPtr<T> &x, const SPtr<T> &y) {
- return(x.get() == y.get());
-}
-
-template
-<class T>
-inline bool operator!=(const SPtr<T> &x, const SPtr<T> &y) {
- return(x.get() != y.get());
-}
-
-#endif // _SPTR_H_
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Semaphore.h b/usr/src/cmd/lms/SyncLib/Include/Semaphore.h
deleted file mode 100644
index 0155f02289..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Semaphore.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Semaphore.h
-//
-// This file contains the definition of the Semaphore class
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_SEMAPHORE_H
-#define _LAD_SEMAPHORE_H
-
-class OSSemaphore;
-
-class Semaphore
-{
-public:
- Semaphore(int maxval = 1);
- Semaphore (const Semaphore &rhs);
- ~Semaphore();
-
- void acquire(); // blocks until value !=0, and decrements the value
- void release(); // increments the value by 1
- bool acquireTry(); // try to acquire the semaphore: return 'true' if succeded
-
- Semaphore &operator=(const Semaphore &rhs);
-
-private:
- OSSemaphore *_osSemaphore;
-};
-
-#endif //_LAD_SEMAPHORE_H
-
diff --git a/usr/src/cmd/lms/SyncLib/Include/Thread.h b/usr/src/cmd/lms/SyncLib/Include/Thread.h
deleted file mode 100644
index c6060ec592..0000000000
--- a/usr/src/cmd/lms/SyncLib/Include/Thread.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// Thread.h
-//
-// This file contains an OS independent interface for thread manipulation
-// A Thread class is defined for easy usage.
-//
-// Usage:
-//
-// Option 1: Construct an instance of the "Thread" class with an external
-// callback function. When calling the "start" method, the thread will be
-// started on the callback function
-//
-// Option 2: Subclass the "Thread" class and reimplement the virtual "run"
-// method. When calling the "start" method, the thread will be started
-// on the "run" function.
-//
-// Implementation overview:
-// Calling the "start" method will start the new thread, which will call the
-// "run" method. The default implementation of the "run" method will call
-// the Callback function given in the constructor.
-//
-//////////////////////////////////////////////////////////////////////////
-#ifndef _LAD_THREAD_H
-#define _LAD_THREAD_H
-
-#ifndef WAIT_INFINITE
-#define WAIT_INFINITE 0xffffffff
-#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
-typedef void (*CallbackFunction) (void *);
-
-class OSThread;
-
-class Thread
-{
- friend class OSThread;
-
-public:
- Thread(CallbackFunction func = NULL, void *param = NULL);
- Thread(const Thread &rhs);
- virtual ~Thread();
-
- // wait for the thread to complete; return true if the thread completed,
- // false on timeout
- bool wait(unsigned long msecs = WAIT_INFINITE) const;
- // start the new thread, return true on success
- bool start();
- // true if the thread is in running state
- bool running() const;
- // measure the time (in msecs) from thread start-time
- long elapsedTime() const;
-
- // return ID for the current thread
- static unsigned long currentThread();
- // put the current thread to sleep
- static void msleep(long msecs);
-
- Thread &operator=(const Thread &rhs);
-
-protected:
- virtual void run();
-
-private:
- CallbackFunction _func;
- void *_param;
- long _startTime;
- OSThread *_osThread;
-};
-
-#endif //_LAD_THREAD_H
-
diff --git a/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp b/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp
deleted file mode 100644
index 8a704a19f1..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/EventUnix.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// EventLinux.cpp
-//
-// This file contains the linux implementation of the Event class
-//////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Event.h"
-#include "SPtr.h"
-#include <pthread.h>
-#include <cerrno>
-#include <sys/time.h>
-#include <iostream>
-
-class OSEvent_s
-{
-public:
- OSEvent_s()
- {
- pthread_mutex_init(&_mut, NULL);
- pthread_cond_init(&_cond, NULL);
- _set = false;
- }
-
- ~OSEvent_s()
- {
- pthread_cond_destroy(&_cond);
- pthread_mutex_destroy(&_mut);
- }
-
- pthread_mutex_t _mut;
- pthread_cond_t _cond;
- bool _set;
-};
-
-class OSEvent
-{
-public:
- OSEvent()
- {
- _ose = SPtr<OSEvent_s>(new OSEvent_s);
- }
-
- ~OSEvent()
- {
- _ose = SPtr<OSEvent_s>(NULL);
- }
-
- SPtr<OSEvent_s> _ose;
-};
-
-Event::Event(bool manual)
-{
- _osEvent = new OSEvent;
-
- /*
- _osEvent->ose->_set = false;
- pthread_mutex_init(&_osEvent->ose->_mut, NULL);
- pthread_cond_init(&_osEvent->ose->_cond, NULL);
- */
-}
-
-Event::Event(const Event &rhs)
-{
- _osEvent = new OSEvent;
- _osEvent->_ose = rhs._osEvent->_ose;
- /*
- _osEvent->_mut = rhs._osEvent->_mut;
- _osEvent->_cond = rhs._osEvent->_cond;
- */
-}
-
-Event::~Event()
-{
- /*
- pthread_cond_destroy(&_osEvent->ose->_cond);
- pthread_mutex_destroy(&_osEvent->ose->_mut);
- */
- delete _osEvent;
-}
-
-bool Event::wait(unsigned long msecs_p)
-{
- int retcode = 0;
-
- if (msecs_p != WAIT_INFINITE) {
- timeval now;
- timespec timeout, time;
-
- gettimeofday(&now, NULL);
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- timeout.tv_sec = now.tv_sec + time.tv_sec;
- timeout.tv_nsec = now.tv_usec + time.tv_nsec;
-
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- //printf("@@@@ Event (%p) wait (cond %p), set: %d (to %d)\n",
- // this, &_osEvent->_ose->_cond, _osEvent->_ose->_set, msecs_p);
- if (!_osEvent->_ose->_set) {
- retcode = pthread_cond_timedwait(&_osEvent->_ose->_cond,
- &_osEvent->_ose->_mut,
- &timeout);
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- _osEvent->_ose->_set = false;
- }
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-
- if (retcode == ETIMEDOUT) {
- return false;
- } else {
- return true;
- }
- } else {
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- //printf("@@@@ Event (%p) wait (cond %p), set: %d\n",
- // this, &_osEvent->_ose->_cond, _osEvent->_ose->_set);
- if (!_osEvent->_ose->_set) {
- pthread_cond_wait(&_osEvent->_ose->_cond, &_osEvent->_ose->_mut);
- }
- _osEvent->_ose->_set = false;
- //printf("@@@@ Event (%p) after wait, set: %d\n", this, _osEvent->_ose->_set);
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
- return true;
- }
-
-}
-
-void Event::set()
-{
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- pthread_cond_signal(&_osEvent->_ose->_cond);
- //printf("@@@@ Event (%p) set (cond %p)\n", this, &_osEvent->_ose->_cond);
- _osEvent->_ose->_set = true;
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-}
-
-void Event::reset()
-{
- pthread_mutex_lock(&_osEvent->_ose->_mut);
- // only way to reset the condition is to destroy it and restart it
- pthread_cond_destroy(&_osEvent->_ose->_cond);
- pthread_cond_init(&_osEvent->_ose->_cond, NULL);
- _osEvent->_ose->_set = false;
- pthread_mutex_unlock(&_osEvent->_ose->_mut);
-}
diff --git a/usr/src/cmd/lms/SyncLib/src/RWLock.cpp b/usr/src/cmd/lms/SyncLib/src/RWLock.cpp
deleted file mode 100644
index 0cfedfe322..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/RWLock.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "RWLock.h"
-
-RWLock::RWLock() : _counter(0) {}
-
-void RWLock::acquire(const RWMode mode_p)
-{
-
- if (mode_p == READ_ONLY) {
- //wait for writer's exit
- _writeSem.acquire();
- //might be blocked only to decrement _counter and _readSem.release() in release()
- _countSem.acquire();
- int tmp = ++_counter;
- _countSem.release();
- if (tmp == 1) {
- //never blocks, no writers, first reader
- _readSem.acquire();
- }
- _writeSem.release();
- } else {
- _writeSem.acquire();
- //wait for reader's exit
- _readSem.acquire();
- }
-
- return;
-}
-
-//will do nothing if no read-write lock was acquired
-void RWLock::switch2RO()
-{
- _countSem.acquire();
- if (!_counter) {
- _counter = 1;
- _writeSem.release();
- }
- _countSem.release();
-}
-
-//will do nothing if no lock was acquired
-void RWLock::release()
-{
-
- //might be blocked only to increment _counter in read-only mode
- _countSem.acquire();
- if (_counter) {
- //read-only mode
- _counter--;
- if (!_counter) {
- //the last reader
- _readSem.release();
- }
- } else {
- //read-write mode
- _readSem.release();
- _writeSem.release();
- }
- _countSem.release();
-
- return;
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp b/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp
deleted file mode 100644
index cff933922c..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/SemaphoreUnix.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// SemaphoreLinux.cpp
-//
-// This file contains the linux implementation of the Semaphore class
-//////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Semaphore.h"
-#include <semaphore.h>
-
-class OSSemaphore {
-public:
- sem_t _sem;
-};
-
-Semaphore::Semaphore(int maxval)
-{
- _osSemaphore = new OSSemaphore;
- sem_init(&_osSemaphore->_sem, 0, maxval);
-}
-
-Semaphore::~Semaphore()
-{
- sem_destroy(&_osSemaphore->_sem);
- delete _osSemaphore;
-}
-
-void Semaphore::acquire()
-{
- // blocks until value !=0, and decrements the value
- sem_wait(&_osSemaphore->_sem);
-}
-
-void Semaphore::release()
-{
- // increments the value by 1
- sem_post(&_osSemaphore->_sem);
-}
-
-bool Semaphore::acquireTry()
-{
- // try to acquire the semaphore: return 'true' if succeded
- return (sem_trywait(&_osSemaphore->_sem) == 0);
-}
-
diff --git a/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp b/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp
deleted file mode 100644
index ce92afae13..0000000000
--- a/usr/src/cmd/lms/SyncLib/src/ThreadUnix.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//////////////////////////////////////////////////////////////////////////
-// ThreadLinux.cpp
-//
-// This file contains the linux implementation of the Thread class
-///////////////////////////////////////////////////////////////////////////
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "Thread.h"
-#include <pthread.h>
-#include <sys/time.h>
-#include <cerrno>
-#include <cstdio>
-
-
-class OSThread
-{
-public:
- pthread_t _handle;
- pthread_cond_t _cond;
- pthread_mutex_t _mut;
- bool _running;
- static void *threadFunc(void * thread_p);
-};
-
-
-void *OSThread::threadFunc(void *thread_p)
-{
- if (thread_p) {
- Thread *t = (Thread*)thread_p;
- //printf("@@@@ OSThread::threadFunc (%p)\n", t->_osThread);
- t->run();
- //printf("@@@@ OSThread::threadFunc (%p) after run\n", t->_osThread);
- pthread_mutex_lock(&t->_osThread->_mut);
- t->_osThread->_running = false;
- //printf("@@@@ OSThread::threadFunc setting signal\n");
- pthread_cond_signal(&t->_osThread->_cond);
- pthread_mutex_unlock(&t->_osThread->_mut);
- }
- return (void *)0;
-}
-
-Thread::Thread(CallbackFunction func_p, void* param_p)
-{
- _osThread = new OSThread;
- _osThread->_handle = 0;
- _osThread->_running = false;
- pthread_mutex_init(&_osThread->_mut, NULL);
- pthread_cond_init(&_osThread->_cond, NULL);
- _func = func_p;
- _param = param_p;
-}
-
-Thread::~Thread()
-{
- pthread_cond_destroy(&_osThread->_cond);
- pthread_mutex_destroy(&_osThread->_mut);
- delete _osThread;
-}
-
-unsigned long Thread::currentThread()
-{
- return pthread_self();
-}
-
-bool Thread::wait(unsigned long msecs_p) const
-{
- int retcode = 0;
-
- if (msecs_p != WAIT_INFINITE) {
- timeval now;
- timespec timeout, time;
-
- gettimeofday(&now, NULL);
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- timeout.tv_sec = now.tv_sec + time.tv_sec;
- timeout.tv_nsec = now.tv_usec + time.tv_nsec;
-
- pthread_mutex_lock(&_osThread->_mut);
- if (_osThread->_running) {
- retcode = pthread_cond_timedwait(&_osThread->_cond, &_osThread->_mut, &timeout);
- }
- pthread_mutex_unlock(&_osThread->_mut);
-
- if (retcode == ETIMEDOUT) {
- return false;
- } else {
- return true;
- }
- } else {
- pthread_mutex_lock(&_osThread->_mut);
- //printf("@@@@ Thread wait (%p), running: %d\n", _osThread, _osThread->_running);
- if (_osThread->_running) {
- pthread_cond_wait(&_osThread->_cond, &_osThread->_mut);
- _osThread->_running = false;
- }
- //printf("@@@@ Thread after wait\n");
- pthread_mutex_unlock(&_osThread->_mut);
- return true;
- }
-}
-
-bool Thread::start()
-{
- if (running() == false) {
- timeval now;
- struct timezone tz;
-
- gettimeofday(&now, &tz);
- _startTime = now.tv_sec;
- _osThread->_running = true;
- if (pthread_create(&_osThread->_handle, NULL, OSThread::threadFunc, this) != 0) {
- return false;
- }
- }
-
- return true;
-}
-
-bool Thread::running() const
-{
- return (_osThread->_running);
-}
-
-void Thread::msleep(long msecs_p)
-{
- timespec time, rem;
- int counter = 5; // givin it 5 tries
-
- time.tv_sec = msecs_p / 1000;
- time.tv_nsec = (msecs_p % 1000) * 1000000;
- while (counter > 0) {
- // nanosleep might return due to a signal, in which case
- // rem will include the remaining time
- if (nanosleep(&time, &rem) == -1) {
- time.tv_sec = rem.tv_sec;
- time.tv_nsec = rem.tv_nsec;
- --counter;
- } else {
- break;
- }
- }
-}
-
-void Thread::run()
-{
- if (_func != NULL) {
- _func(_param);
- }
-}
-
-long Thread::elapsedTime() const
-{
- struct timezone tz;
- timeval now;
-
- gettimeofday(&now, &tz);
- return ((now.tv_sec - _startTime)*1000);
-}
-
diff --git a/usr/src/cmd/lms/THIRDPARTYLICENSE b/usr/src/cmd/lms/THIRDPARTYLICENSE
deleted file mode 100644
index 211d58eec2..0000000000
--- a/usr/src/cmd/lms/THIRDPARTYLICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright (C) 2004-2008 Intel Corp. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- - Neither the name of Intel Corp. nor the names of its
- contributors may be used to endorse or promote products derived from this
- software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip b/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip
deleted file mode 100644
index 5dc6a98f71..0000000000
--- a/usr/src/cmd/lms/THIRDPARTYLICENSE.descrip
+++ /dev/null
@@ -1 +0,0 @@
-INTEL ACTIVE MANAGEMENT TECHNOLOGY LOCAL MANAGEABILITY SERVICE SOFTWARE
diff --git a/usr/src/cmd/lms/glue.cpp b/usr/src/cmd/lms/glue.cpp
deleted file mode 100644
index 53cf442a19..0000000000
--- a/usr/src/cmd/lms/glue.cpp
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdlib>
-#include <cstdio>
-#include <cstring>
-#include <sys/types.h>
-#include <dlfcn.h>
-#include "glue.h"
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#endif // __sun
-
-#define PARSER_MAX 32
-
-typedef struct parser_s {
- unsigned int count;
- char *line[PARSER_MAX];
-} parser_t;
-
-
-static void parser_init(parser_t *cfg)
-{
- if (!cfg) {
- return;
- }
-
- cfg->count = 0;
-}
-
-static int parser_add(parser_t *cfg, char *buf)
-{
- if ((!cfg) || (cfg->count > PARSER_MAX)) {
- return -1;
- }
-
- cfg->line[cfg->count] = strdup(buf);
- if (cfg->line[cfg->count]) {
- cfg->count ++;
- }
-
- return 0;
-}
-
-static int parser_length(parser_t *cfg)
-{
- if (!cfg) {
- return 0;
- }
-
- return cfg->count;
-}
-
-static char *parser_get(parser_t *cfg, unsigned int index)
-{
- if ((!cfg) || (index >= cfg->count)) {
- return NULL;
- }
-
- return (cfg->line[index]);
-}
-
-
-static int parser_read(parser_t *cfg, FILE *fp)
-{
- char line[512];
- char *head, *tail;
- int len;
-
- if ((!fp) || (!cfg)) {
- return -1;
- }
-
- while (fgets(line, 511, fp)) {
- head = line;
- while (*head == 0x20 || *head == '\t') {
- head ++;
- }
- if ((*head == '#') || (*head == '\n') ||
- (*head == '\r') || (*head == '\0')) {
- continue;
- }
- len = strlen(head);
- tail = head + len - 1;
- if (tail <= head) {
- continue;
- }
- while ((*tail == '\r') || (*tail == '\n')) {
- tail --;
- }
- *(tail + 1) = '\0';
-
- parser_add(cfg, head);
- }
- return 0;
-}
-
-static void parser_free(parser_t *cfg)
-{
- unsigned int i;
-
- for (i = 0; i < cfg->count; i ++) {
- free(cfg->line[i]);
- }
-}
-
-
-/* glue functions */
-
-void glue::handle_init(int index, const char *file)
-{
- int i = index;
-
- if (!file) {
- return;
- }
- printf("file:%s\n", file);
-
- funcs[i].handle = dlopen(file, RTLD_NOW);
- if (!funcs[i].handle) {
- printf("can't open:%s, %s\n", file, dlerror());
- return;
- }
-
- funcs[i].init_funcs = (lms_init_t)dlsym(funcs[i].handle,
- LMS_INIT_FUNC_NAME);
- if (!funcs[i].init_funcs) {
- printf("dl error:%s\n", dlerror());
- return;
- }
-
- if (LMS_OK != funcs[i].init_funcs()) {
- return;
- }
-
- funcs[i].version_funcs = (lms_version_t)dlsym(funcs[i].handle,
- LMS_VERSION_FUNC_NAME);
- funcs[i].pre_funcs = (lms_pre_t)dlsym(funcs[i].handle,
- LMS_PRE_FUNC_NAME);
- funcs[i].retry_funcs = (lms_retry_t)dlsym(funcs[i].handle,
- LMS_RETRY_FUNC_NAME);
- funcs[i].post_funcs = (lms_post_t)dlsym(funcs[i].handle,
- LMS_POST_FUNC_NAME);
- funcs[i].deinit_funcs = (lms_deinit_t)dlsym(funcs[i].handle,
- LMS_DEINIT_FUNC_NAME);
-}
-
-int glue::mem_init(void)
-{
- int i;
-
- funcs = new glue_funcs[cnt];
- if (!funcs) {
- return LMS_ERROR;
- }
-
- for (i = 0;i < cnt; i++) {
- funcs[i].handle = NULL;
- funcs[i].init_funcs = NULL;
- funcs[i].version_funcs = NULL;
- funcs[i].pre_funcs = NULL;
- funcs[i].retry_funcs = NULL;
- funcs[i].post_funcs = NULL;
- funcs[i].deinit_funcs = NULL;
- }
-
- return LMS_OK;
-}
-
-glue::glue() : funcs(NULL)
-{
-}
-
-glue::~glue()
-{
-}
-
-
-int glue::init(void)
-{
- FILE *fp;
- parser_t cfg;
- int i;
-
- parser_init(&cfg);
-
- fp = fopen(LMS_PLUGIN_CONFIG_FILE, "rb");
- if ((!fp) || (parser_read(&cfg, fp) != 0)) {
- cnt = 0;
- if (fp) {
- fclose(fp);
- }
- return LMS_OK;
- }
-
- do {
- cnt = parser_length(&cfg);
- if (0 == cnt) {
- break;
- }
- if (mem_init()) {
- break;
- }
- for (i = 0; i < cnt; i++) {
- handle_init(i, parser_get(&cfg, i));
- }
- } while (0);
-
- fclose(fp);
- parser_free(&cfg);
- return LMS_OK;
-}
-
-void glue::deinit(void)
-{
- int i;
-
- if (!funcs) {
- return;
- }
-
- for (i = 0; i < cnt; i++) {
- if (funcs[i].deinit_funcs) {
- funcs[i].deinit_funcs();
- }
- if (funcs[i].handle) {
- dlclose(funcs[i].handle);
- }
- }
-
- delete[] funcs;
-}
-
-void glue::version(unsigned char version)
-{
- int i;
-
- if (!funcs) {
- return;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].version_funcs) {
- continue;
- }
- funcs[i].version_funcs(version);
- }
-}
-
-int glue::preprocess(unsigned char *buff, int len)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].pre_funcs) {
- continue;
- }
- ret = funcs[i].pre_funcs(buff, len);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
-int glue::retry(unsigned char *buff, int len)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].retry_funcs) {
- continue;
- }
- ret = funcs[i].retry_funcs(buff, len);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
-
-int glue::postprocess(unsigned char *buff, int len, int status)
-{
- int i;
- int ret = LMS_ACCEPTED;
-
- if (!funcs) {
- return ret;
- }
-
- for (i = 0; i < cnt; i++) {
- if (!funcs[i].post_funcs) {
- continue;
- }
- ret = funcs[i].post_funcs(buff, len, status);
- if (ret != LMS_ACCEPTED) {
- return ret;
- }
- }
-
- return LMS_ACCEPTED;
-}
-
diff --git a/usr/src/cmd/lms/glue.h b/usr/src/cmd/lms/glue.h
deleted file mode 100644
index daa6d138b4..0000000000
--- a/usr/src/cmd/lms/glue.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __LMS_GLUE_H__
-#define __LMS_GLUE_H__
-
-#include "plugin.h"
-
-
-class glue_funcs
-{
-public:
- void *handle;
- lms_init_t init_funcs;
- lms_version_t version_funcs;
- lms_pre_t pre_funcs;
- lms_retry_t retry_funcs;
- lms_post_t post_funcs;
- lms_deinit_t deinit_funcs;
-};
-
-
-class glue
-{
-public:
- glue();
- ~glue();
-
- int init(void);
- void deinit(void);
- void version(unsigned char version);
- int preprocess(unsigned char *buff, int len);
- int retry(unsigned char *buff, int len);
- int postprocess(unsigned char *buff, int len, int status);
-
-private:
- int cnt;
- int mem_init(void);
- void handle_init(int index, const char *file);
- glue_funcs *funcs;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/heci/FWULCommand.cpp b/usr/src/cmd/lms/heci/FWULCommand.cpp
deleted file mode 100644
index 790ce7e5b8..0000000000
--- a/usr/src/cmd/lms/heci/FWULCommand.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#endif // __sun
-
-#include "FWULCommand.h"
-
-FWULCommand::FWULCommand(bool verbose) :
-FWULClient(FW_UPDATE_GUID, verbose)
-{
- _verbose = verbose;
-}
-
-FWULCommand::~FWULCommand(void)
-{
-}
-
-HECI_STATUS FWULCommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize)
-{
- UINT32 inBuffSize;
- *outBuffSize = 0;
-
- inBuffSize = FWULClient.GetBufferSize();
- if (NULL == *readBuffer)
- {
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Malloc failed\n");
- }
- return HECI_STATUS_MEMORY_ALLOCATION_ERROR;
- }
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = FWULClient.SendMessage(command, command_size);
- if ((UINT32)bytesWritten != command_size)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not send data to FWUpdate client through MEI\n");
- }
- return HECI_STATUS_MSG_TRANSMISSION_ERROR;
- }
- *outBuffSize = FWULClient.ReceiveMessage(*readBuffer, inBuffSize, 15000);
- if (0 == *outBuffSize)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not read data from FWUpdate client through MEI\n");
- }
- return HECI_STATUS_UNEXPECTED_RESPONSE;
- }
- if (_verbose)
- {
- fprintf(stdout, "Data received from FWUpdate Client. %d bytes read\n", *outBuffSize);
- }
- return HECI_STATUS_OK;
-}
-
-
-/*
- * Get ME data information from FW update client using AMTCommunication class
- */
-HECI_STATUS
-FWULCommand::GetFWUVersionAndInfo(FWU_GET_VERSION_MSG_REPLY &verMsg, FWU_GET_INFO_MSG_REPLY &infoMsg)
-{
- UINT8 *readBuffer = NULL;
- UINT32 command_size = sizeof(ME_GET_FW_UPDATE_INFO_REQUEST);
- UINT32 replySize = 0;
- ME_GET_FW_UPDATE_INFO_REQUEST msg;
- HECI_STATUS status;
-
- msg.MessageID = FWU_GET_VERSION;
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
- if (status != HECI_STATUS_OK)
- {
- goto fwuvend;
- }
- if (replySize == sizeof(FWU_GET_VERSION_MSG_REPLY))
- {
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->MessageType != FWU_GET_VERSION_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- memcpy(&verMsg, readBuffer, sizeof(FWU_GET_VERSION_MSG_REPLY));
-
- msg.MessageID = FWU_GET_INFO;
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
- if (status != HECI_STATUS_OK)
- {
- goto fwuvend;
- }
- if (replySize != sizeof(FWU_GET_INFO_MSG_REPLY))
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->MessageType != FWU_GET_INFO_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- memcpy(&infoMsg, readBuffer, sizeof(FWU_GET_INFO_MSG_REPLY));
-
- }
- else if (replySize == sizeof(FWU_GET_VERSION_MSG_REPLY_V3))
- {
- if (((FWU_MSG_REPLY_HEADER_V3 *)readBuffer)->MessageType != FWU_GET_VERSION_REPLY)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MessageType in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
- if (((FWU_MSG_REPLY_HEADER_V3 *)readBuffer)->Status != PT_STATUS_SUCCESS)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Status in MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
- FWU_GET_VERSION_MSG_REPLY_V3 *rep = (FWU_GET_VERSION_MSG_REPLY_V3 *)readBuffer;
- verMsg.MessageType = FWU_GET_VERSION_REPLY;
- verMsg.Status = rep->Status;
- verMsg.Sku = rep->Sku;
- verMsg.ICHVer = rep->ICHVer;
- verMsg.MCHVer = rep->MCHVer;
- verMsg.Vendor = rep->Vendor;
- verMsg.LastFwUpdateStatus = rep->LastFwUpdateStatus;
- verMsg.HwSku = rep->Sku;
- memcpy(&verMsg.CodeVersion, &(rep->CodeVersion), sizeof(verMsg.CodeVersion));
- memset(&verMsg.AMTVersion, 0, sizeof(verMsg.AMTVersion));
- verMsg.EnabledUpdateInterfaces = rep->EnabledUpdateInterfaces;
- verMsg.Reserved = 0;
-
- memset(&infoMsg, 0, sizeof(infoMsg));
- } else {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto fwuvend;
- }
-
-fwuvend:
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
-
- return status;
-}
diff --git a/usr/src/cmd/lms/heci/FWULCommand.h b/usr/src/cmd/lms/heci/FWULCommand.h
deleted file mode 100644
index a8049da338..0000000000
--- a/usr/src/cmd/lms/heci/FWULCommand.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __FWUL_COMMAND_H__
-#define __FWUL_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-
-#pragma pack(1)
-
-typedef struct _FWU_VERSION
-{
- UINT16 Major;
- UINT16 Minor;
- UINT16 Hotfix;
- UINT16 Build;
-} FWU_VERSION;
-
-typedef enum
-{
- FWU_GET_VERSION = 0,
- FWU_GET_VERSION_REPLY,
- FWU_START,
- FWU_START_REPLY,
- FWU_DATA,
- FWU_DATA_REPLY,
- FWU_END,
- FWU_END_REPLY,
- FWU_GET_INFO,
- FWU_GET_INFO_REPLY
-} FWU_HECI_MESSAGE_TYPE;
-
-typedef struct _ME_GET_FW_UPDATE_INFO_REQUEST
-{
- UINT32 MessageID;
-} ME_GET_FW_UPDATE_INFO_REQUEST;
-
-typedef struct _FWU_MSG_REPLY_HEADER
-{
- UINT32 MessageType;
- UINT32 Status;
-} FWU_MSG_REPLY_HEADER;
-
-typedef struct _FWU_MSG_REPLY_HEADER_V3
-{
- UINT8 MessageType;
- UINT32 Status;
-} FWU_MSG_REPLY_HEADER_V3;
-
-typedef struct _FWU_GET_VERSION_MSG_REPLY
-{
- UINT32 MessageType;
- UINT32 Status;
- UINT32 Sku;
- UINT32 ICHVer;
- UINT32 MCHVer;
- UINT32 Vendor;
- UINT32 LastFwUpdateStatus;
- UINT32 HwSku;
- FWU_VERSION CodeVersion;
- FWU_VERSION AMTVersion;
- UINT16 EnabledUpdateInterfaces;
- UINT16 Reserved;
-} FWU_GET_VERSION_MSG_REPLY;
-
-typedef struct _FWU_GET_VERSION_MSG_REPLY_V3
-{
- UINT8 MessageType;
- UINT32 Status;
- UINT32 Sku;
- UINT32 ICHVer;
- UINT32 MCHVer;
- UINT32 Vendor;
- FWU_VERSION CodeVersion;
- FWU_VERSION RcvyVersion;
- UINT16 EnabledUpdateInterfaces;
- UINT32 LastFwUpdateStatus;
- UINT32 Reserved;
-} FWU_GET_VERSION_MSG_REPLY_V3;
-
-typedef struct _FWU_GET_INFO_MSG_REPLY
-{
- UINT32 MessageType;
- UINT32 Status;
- FWU_VERSION MEBxVersion;
- UINT32 FlashOverridePolicy;
- UINT32 ManageabilityMode;
- UINT32 BiosBootState;
- struct {
- UINT32 CryptoFuse :1;
- UINT32 FlashProtection:1;
- UINT32 FwOverrideQualifier:2;
- UINT32 MeResetReason:2;
- UINT32 FwOverrideCounter:8;
- UINT32 reserved:18;
- } Fields;
- UINT8 BiosVersion[20];
-} FWU_GET_INFO_MSG_REPLY;
-
-#pragma pack(0)
-
-class FWULCommand
-{
-public:
- FWULCommand(bool verbose = false);
- ~FWULCommand();
-
- HECI_STATUS GetFWUVersionAndInfo(FWU_GET_VERSION_MSG_REPLY &verMsg, FWU_GET_INFO_MSG_REPLY &infoMsg);
-
- HECILinux FWULClient;
-
-private:
- HECI_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize);
-
- bool _verbose;
-};
-
-#endif //__FWUL_COMMAND_H__
-
diff --git a/usr/src/cmd/lms/heci/HECIUnix.cpp b/usr/src/cmd/lms/heci/HECIUnix.cpp
deleted file mode 100644
index 1334ef1352..0000000000
--- a/usr/src/cmd/lms/heci/HECIUnix.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <cerrno>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <aio.h>
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#endif // __sun
-
-#include "HECIUnix.h"
-
-#pragma pack(1)
-
-typedef struct heci_ioctl_data
-{
- uint32_t size;
- char *data;
-#ifndef _LP64
- /*
- * If lms is compiled in 32-bit, padding is needed to
- * talk to the driver which is 64-bit only.
- */
- char *pad;
-#endif
-} heci_ioctl_data_t;
-
-/* IOCTL commands */
-#undef HECI_IOCTL
-#undef IOCTL_HECI_GET_VERSION
-#undef IOCTL_HECI_CONNECT_CLIENT
-#undef IOCTL_HECI_WD
-#define HECI_IOCTL_TYPE 0x48
-#define IOCTL_HECI_GET_VERSION \
- _IOWR(HECI_IOCTL_TYPE, 0x0, heci_ioctl_data_t)
-#define IOCTL_HECI_CONNECT_CLIENT \
- _IOWR(HECI_IOCTL_TYPE, 0x01, heci_ioctl_data_t)
-#define IOCTL_HECI_WD \
- _IOWR(HECI_IOCTL_TYPE, 0x02, heci_ioctl_data_t)
-#define IAMT_HECI_GET_RECEIVED_MESSAGE_DATA \
- _IOW(HECI_IOCTL_TYPE, 0x03, heci_ioctl_data_t)
-
-#pragma pack(0)
-
-/***************************** public functions *****************************/
-
-HECILinux::HECILinux(const GUID guid, bool verbose) :
-HECI(guid, verbose),
-_fd(-1),
-m_haveHeciVersion(false)
-{
-}
-
-HECILinux::~HECILinux()
-{
- if (_fd != -1) {
- close(_fd);
- }
-}
-
-bool HECILinux::GetHeciVersion(HECI_VERSION &version) const
-{
- if (m_haveHeciVersion) {
- memcpy(&version, &m_heciVersion, sizeof(HECI_VERSION));
- return true;
- }
- return false;
-}
-
-bool HECILinux::Init(unsigned char reqProtocolVersion)
-{
- int result;
- HECI_CLIENT *heci_client;
- bool return_result = true;
- heci_ioctl_data_t version_response;
- heci_ioctl_data_t client_connect;
-
- m_haveHeciVersion = false;
- if (_initialized) {
- Deinit();
- }
-
- _fd = open("/dev/heci", O_RDWR);
-
- if (_fd == -1 ) {
- if (_verbose) {
- fprintf(stderr, "Error: Cannot establish a handle to the HECI driver\n");
- }
- return false;
- }
- _initialized = true;
- version_response.size = sizeof(HECI_VERSION);
- version_response.data = (char *)malloc(version_response.size);
- if (!version_response.data) {
- if (_verbose) {
- fprintf(stderr, "malloc failure.\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
-
- result = ioctl(_fd, IOCTL_HECI_GET_VERSION, &version_response);
- if (result) {
- if (_verbose) {
- fprintf(stderr, "error in IOCTL_HECI_GET_VERSION recieve message. err=%d\n", result);
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- memcpy(&m_heciVersion, version_response.data, sizeof(HECI_VERSION));
- m_haveHeciVersion = true;
- if (_verbose) {
- fprintf(stdout, "Connected to HECI driver, version: %d.%d.%d.%d\n",
- m_heciVersion.major, m_heciVersion.minor, m_heciVersion.hotfix, m_heciVersion.build);
- fprintf(stdout, "Size of guid = %lu\n", (unsigned long)sizeof(_guid));
- }
- client_connect.size = sizeof(_guid);
- client_connect.data = (char *)malloc(client_connect.size);
- if (!client_connect.data) {
- if (_verbose) {
- fprintf(stderr, "malloc failure.\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- memcpy(client_connect.data, &_guid, sizeof(_guid));
- result = ioctl(_fd, IOCTL_HECI_CONNECT_CLIENT, &client_connect);
- if (result) {
- if (_verbose) {
- fprintf(stderr, "error in IOCTL_HECI_CONNECT_CLIENT recieve message. err=%d\n", result);
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
- heci_client = (HECI_CLIENT *) client_connect.data;
- if (_verbose) {
- fprintf(stdout, "max_message_length %d \n", (heci_client->MaxMessageLength));
- fprintf(stdout, "protocol_version %d \n", (heci_client->ProtocolVersion));
- }
-
- if ((reqProtocolVersion > 0) && (heci_client->ProtocolVersion != reqProtocolVersion)) {
- if (_verbose) {
- fprintf(stderr, "Error: MEI protocol version not supported\n");
- }
- return_result = false;
- Deinit();
- goto heci_free;
- }
-
- _protocolVersion = heci_client->ProtocolVersion;
- _bufSize = heci_client->MaxMessageLength;
-
-heci_free:
- if (NULL != version_response.data) {
- free(version_response.data);
- }
- if (NULL != client_connect.data) {
- free(client_connect.data);
- }
- return return_result;
-}
-
-void HECILinux::Deinit()
-{
- if (_fd != -1) {
- close(_fd);
- _fd = -1;
- }
-
- _bufSize = 0;
- _protocolVersion = 0;
- _initialized = false;
-}
-
-int HECILinux::ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout)
-{
- int rv = 0;
- int error = 0;
-
- if (_verbose) {
- fprintf(stdout, "call read length = %d\n", len);
- }
- rv = read(_fd, (void*)buffer, len);
- if (rv < 0) {
- error = errno;
- if (_verbose) {
- fprintf(stderr, "read failed with status %d %d\n", rv, error);
- }
- Deinit();
- } else {
- if (_verbose) {
- fprintf(stderr, "read succeded with result %d\n", rv);
- }
- }
- return rv;
-}
-
-int HECILinux::SendMessage(const unsigned char *buffer, int len, unsigned long timeout)
-{
- int rv = 0;
- int return_length =0;
- int error = 0;
- fd_set set;
- struct timeval tv;
-
- tv.tv_sec = timeout / 1000;
- tv.tv_usec =(timeout % 1000) * 1000000;
-
- if (_verbose) {
- fprintf(stdout, "call write length = %d\n", len);
- }
- rv = write(_fd, (void *)buffer, len);
- if (rv < 0) {
- error = errno;
- if (_verbose) {
- fprintf(stderr,"write failed with status %d %d\n", rv, error);
- }
- goto out;
- }
-
- return_length = rv;
-
- FD_ZERO(&set);
- FD_SET(_fd, &set);
- rv = select(_fd+1 ,&set, NULL, NULL, &tv);
- if (rv > 0 && FD_ISSET(_fd, &set)) {
- if (_verbose) {
- fprintf(stderr, "write success\n");
- }
- }
- else if (rv == 0) {
- if (_verbose) {
- fprintf(stderr, "write failed on timeout with status\n");
- }
- goto out;
- }
- else { //rv<0
- if (_verbose) {
- fprintf(stderr, "write failed on select with status %d\n", rv);
- }
- goto out;
- }
-
- rv = return_length;
-
-out:
- if (rv < 0) {
- Deinit();
- }
-
- return rv;
-}
-
diff --git a/usr/src/cmd/lms/heci/HECIUnix.h b/usr/src/cmd/lms/heci/HECIUnix.h
deleted file mode 100644
index 670beb1809..0000000000
--- a/usr/src/cmd/lms/heci/HECIUnix.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __HECI_UNIX_H__
-#define __HECI_UNIX_H__
-
-#include "heci.h"
-
-class HECILinux : public HECI
-{
-public:
- HECILinux(const GUID guid, bool verbose = false);
- virtual ~HECILinux();
-
- virtual bool Init(unsigned char reqProtocolVersion = 0);
- virtual void Deinit();
- virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = 2000);
- virtual int SendMessage(const unsigned char *buffer, int len, unsigned long timeout = 2000);
- virtual unsigned int GetBufferSize() const { return _bufSize; }
- virtual unsigned char GetProtocolVersion() const { return _protocolVersion; }
- virtual bool GetHeciVersion(HECI_VERSION &version) const;
- virtual bool IsInitialized() const { return _initialized; }
-
-private:
- int _fd;
- bool m_haveHeciVersion;
- HECI_VERSION m_heciVersion;
-};
-
-#endif // __HECI_UNIX_H__
diff --git a/usr/src/cmd/lms/heci/HECI_if.h b/usr/src/cmd/lms/heci/HECI_if.h
deleted file mode 100644
index 5dd1fa824f..0000000000
--- a/usr/src/cmd/lms/heci/HECI_if.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __HECI_INTRFACE_H__
-#define __HECI_INTRFACE_H__
-
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int UINT32;
-typedef char CHAR;
-typedef unsigned long ULONG;
-typedef UINT32 AMT_STATUS;
-typedef UINT32 AMT_BOOLEAN;
-
-typedef enum _HECI_STATUS {
- HECI_STATUS_OK = 0x0,
- HECI_STATUS_GENERAL_ERROR = 0x2000,
- HECI_STATUS_LOCATE_DEVICE_ERROR,
- HECI_STATUS_MEMORY_ACCESS_ERROR,
- HECI_STATUS_WRITE_REGISTER_ERROR,
- HECI_STATUS_MEMORY_ALLOCATION_ERROR,
- HECI_STATUS_BUFFER_OVEREFLOW_ERROR,
- HECI_STATUS_NOT_ENOUGH_MEMORY,
- HECI_STATUS_MSG_TRANSMISSION_ERROR,
- HECI_STATUS_VERSION_MISMATCH,
- HECI_STATUS_UNEXPECTED_INTERRUPT_REASON,
- HECI_STATUS_TIMEOUT_ERROR,
- HECI_STATUS_UNEXPECTED_RESPONSE,
- HECI_STATUS_UNKNOWN_MESSAGE,
- HECI_STATUS_CANNOT_FOUND_HOST_CLIENT,
- HECI_STATUS_CANNOT_FOUND_ME_CLIENT,
- HECI_STATUS_CLIENT_ALREADY_CONNECTED,
- HECI_STATUS_NO_FREE_CONNECTION,
- HECI_STATUS_ILLEGAL_PARAMETER,
- HECI_STATUS_FLOW_CONTROL_ERROR,
- HECI_STATUS_NO_MESSAGE,
- HECI_STATUS_BUFFER_TOO_LARGE,
- HECI_STATUS_BUFFER_TOO_SMALL,
- HECI_STATUS_BUFFER_NOT_EMPTY,
- NUM_OF_HECI_STATUSES
-} HECI_STATUS;
-
-const GUID HECI_PTHI = {0x12f80028, 0xb4b7, 0x4b2d, {0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c}};
-
-// Define GUID used to connect to the FWUpdate client (via the HECI device)
-// {309DCDE8-CCB1-4062-8F78-600115A34327}
-const GUID FW_UPDATE_GUID = {0x309dcde8, 0xccb1, 0x4062, {0x8f, 0x78, 0x60, 0x1, 0x15, 0xa3, 0x43, 0x27}};
-
-const GUID WD_GUID = {0x05B79A6F, 0x4628, 0x4D7F, {0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB}};
-
-#pragma pack(1)
-
-typedef struct _HECI_VERSION {
- UINT8 major;
- UINT8 minor;
- UINT8 hotfix;
- UINT16 build;
-} HECI_VERSION;
-
-typedef struct _HECI_CLIENT {
- UINT32 MaxMessageLength;
- UINT8 ProtocolVersion;
-} HECI_CLIENT;
-
-typedef union _MEFWCAPS_SKU
-{
- UINT32 Data;
- struct {
- UINT32 Reserved :1; //Legacy
- UINT32 Qst :1; //QST
- UINT32 Asf :1; //ASF2
- UINT32 Amt :1; //AMT Professional
- UINT32 AmtFund :1; //AMT Fundamental
- UINT32 Tpm :1; //TPM
- UINT32 Dt :1; //Danbury Technology
- UINT32 Fps :1; //Fingerprint Sensor
- UINT32 HomeIT :1; //Home IT
- UINT32 Mctp :1; //MCTP
- UINT32 WoX :1; //Wake on X
- UINT32 PmcPatch :1; //PMC Patch
- UINT32 Ve :1; //VE
- UINT32 Tdt :1; //Theft Deterrent Technology
- UINT32 Corp :1; //Corporate
- UINT32 Reserved2 :17;
- } Fields;
-} MEFWCAPS_SKU;
-
-typedef enum _MEFWCAPS_MANAGEABILITY_SUPP
-{
- MEFWCAPS_MANAGEABILITY_SUPP_NONE = 0,
- MEFWCAPS_MANAGEABILITY_SUPP_AMT,
- MEFWCAPS_MANAGEABILITY_SUPP_ASF,
- MEFWCAPS_MANAGEABILITY_SUPP_CP
-} MEFWCAPS_MANAGEABILITY_SUPP;
-
-
-#pragma pack()
-
-#endif // __HECI_INTRFACE_H__
diff --git a/usr/src/cmd/lms/heci/MNGCommand.cpp b/usr/src/cmd/lms/heci/MNGCommand.cpp
deleted file mode 100644
index fc60cc79eb..0000000000
--- a/usr/src/cmd/lms/heci/MNGCommand.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __sun
-#include <stdio.h>
-#include <stdlib.h>
-#endif // __sun
-
-#include "MNGCommand.h"
-
-MNGCommand::MNGCommand(bool verbose) :
-MNGClient(WD_GUID, verbose)
-{
- _verbose = verbose;
-}
-
-MNGCommand::~MNGCommand(void)
-{
-}
-
-HECI_STATUS MNGCommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize)
-{
- UINT32 inBuffSize;
- *outBuffSize = 0;
-
- inBuffSize = MNGClient.GetBufferSize();
- if (NULL == *readBuffer)
- {
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Malloc failed\n");
- }
- return HECI_STATUS_MEMORY_ALLOCATION_ERROR;
- }
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = MNGClient.SendMessage(command, command_size);
- if ((UINT32)bytesWritten != command_size)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not send data to MNG client through MEI\n");
- }
- return HECI_STATUS_MSG_TRANSMISSION_ERROR;
- }
- *outBuffSize = MNGClient.ReceiveMessage(*readBuffer, inBuffSize, 15000);
- if (0 == *outBuffSize)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Could not read data from MNG client through MEI\n");
- }
- return HECI_STATUS_UNEXPECTED_RESPONSE;
- }
- if (_verbose)
- {
- fprintf(stdout, "Data received from MNG Client. %d bytes read\n", *outBuffSize);
- }
- return HECI_STATUS_OK;
-}
-
-
-/*
- * Get ME data information from MNG client
- */
-HECI_STATUS
-MNGCommand::GetMEInfo(MNG_GET_ME_INFORMATION_RESPONSE &infoMsg)
-{
- UINT8 *readBuffer = NULL;
- UINT32 command_size = sizeof(MNG_GET_ME_INFO_HEADER);
- UINT32 replySize = 0;
- MNG_REQUEST msg = MNG_GET_ME_INFO_HEADER;
- HECI_STATUS status;
-
- status = _call((const unsigned char *)&msg, command_size,
- &readBuffer, &replySize);
-
- if (status != HECI_STATUS_OK)
- {
- goto mngend;
- }
- if (replySize != sizeof(MNG_GET_ME_INFORMATION_RESPONSE))
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: Size of MEI response is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto mngend;
- }
- if (((MNG_GET_ME_INFORMATION_RESPONSE *)readBuffer)->Version != MNG_GET_ME_INFO_Version)
- {
- if (_verbose)
- {
- fprintf(stderr, "Error: MEI response size is not as expected\n");
- }
- status = HECI_STATUS_UNEXPECTED_RESPONSE;
- goto mngend;
- }
- memcpy(&infoMsg, readBuffer, sizeof(MNG_GET_ME_INFORMATION_RESPONSE));
-
-mngend:
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
-
- return status;
-}
diff --git a/usr/src/cmd/lms/heci/MNGCommand.h b/usr/src/cmd/lms/heci/MNGCommand.h
deleted file mode 100644
index fbd83b0b23..0000000000
--- a/usr/src/cmd/lms/heci/MNGCommand.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __MNG_COMMAND_H__
-#define __MNG_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-
-#pragma pack(1)
-
-typedef struct _MNG_REQUEST
-{
- UINT8 Cmd;
- UINT8 ByteCount;
- UINT8 SubCmd;
- UINT8 Version;
-} MNG_REQUEST;
-
-typedef struct _MNG_GET_ME_INFORMATION_RESPONSE
-{
- UINT32 Version;
- MEFWCAPS_SKU Sku;
- MEFWCAPS_MANAGEABILITY_SUPP MngMode;
-} MNG_GET_ME_INFORMATION_RESPONSE;
-
-#pragma pack(0)
-
-class MNGCommand
-{
-public:
- MNGCommand(bool verbose = false);
- ~MNGCommand();
-
- HECI_STATUS GetMEInfo(MNG_GET_ME_INFORMATION_RESPONSE &infoMsg);
-
- HECILinux MNGClient;
-
-private:
- HECI_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 *outBuffSize);
-
- bool _verbose;
-
-};
-
-const MNG_REQUEST MNG_GET_ME_INFO_HEADER = {0x07, 0x02, 0x01, 0x10};
-const UINT32 MNG_GET_ME_INFO_Version = 0x00010000;
-
-
-#endif //__MNG_COMMAND_H__
-
diff --git a/usr/src/cmd/lms/heci/PTHICommand.cpp b/usr/src/cmd/lms/heci/PTHICommand.cpp
deleted file mode 100644
index 8fabac6bb9..0000000000
--- a/usr/src/cmd/lms/heci/PTHICommand.cpp
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: PTHICommand.cpp
-//
-//----------------------------------------------------------------------------
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <cstdio>
-#include <cstdlib>
-#include "PTHICommand.h"
-
-
-PTHICommand::PTHICommand(bool verbose, unsigned long sendTimeout) :
-PTHIClient(HECI_PTHI, verbose),
-m_sendTimeout(sendTimeout)
-{
-}
-
-PTHICommand::~PTHICommand(void)
-{
-}
-
-AMT_STATUS PTHICommand::_call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 rcmd, unsigned int expSize)
-{
- UINT32 inBuffSize;
- UINT32 outBuffSize = 0;
-
- inBuffSize = PTHIClient.GetBufferSize();
- *readBuffer = (UINT8 *)malloc(sizeof(UINT8) * inBuffSize);
- if (NULL == *readBuffer)
- {
- return PTSDK_STATUS_RESOURCES;
- }
- memset(*readBuffer, 0, inBuffSize);
-
- int bytesWritten = PTHIClient.SendMessage(command, command_size, m_sendTimeout);
- if ((UINT32)bytesWritten != command_size)
- {
- return AMT_STATUS_INTERNAL_ERROR;
- }
- outBuffSize = PTHIClient.ReceiveMessage(*readBuffer, inBuffSize);
- if (0 == outBuffSize)
- {
- return PTHI_STATUS_EMPTY_RESPONSE;
- }
- AMT_STATUS status = ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Status;
- if (status != AMT_STATUS_SUCCESS)
- {
- return status;
- }
- status = _verifyResponseHeader(rcmd, ((PTHI_RESPONSE_MESSAGE_HEADER *)*readBuffer)->Header, outBuffSize);
- if (status != AMT_STATUS_SUCCESS)
- {
- return status;
- }
- if ((expSize != 0) && (expSize != outBuffSize))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Confirms the correctness of the response message header
-* and the response message size
-* Arguments:
-* command - appropriate Host interface command
-* response_header - reference to the response message header
-* response_size - value that holds the actual size of the
-* response message
-* expected_size - value that holds the expected size of the
-* response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyResponseHeader(
- const UINT32 command, const PTHI_MESSAGE_HEADER &response_header,
- UINT32 response_size)
-{
- AMT_STATUS status = AMT_STATUS_SUCCESS;
-
- if (response_size < sizeof(PTHI_RESPONSE_MESSAGE_HEADER)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_size != (response_header.Length + sizeof(PTHI_MESSAGE_HEADER))) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Command.cmd.val != command) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Reserved != 0) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else if (response_header.Version.MajorNumber != AMT_MAJOR_VERSION
- || response_header.Version.MinorNumber < AMT_MINOR_VERSION) {
- status = AMT_STATUS_INTERNAL_ERROR;
- }
-
- return status;
-}
-
-/*
-* Confirms the correctness of the GetCodeVersions response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyCodeVersions(
- const CFG_GET_CODE_VERSIONS_RESPONSE &response)
-{
- AMT_STATUS status = AMT_STATUS_SUCCESS;
- UINT32 codeVerLen;
- UINT32 ptVerTypeCount;
- UINT32 len = 0;
- UINT32 i;
-
- do {
- codeVerLen = response.Header.Header.Length - sizeof(AMT_STATUS);
- ptVerTypeCount = codeVerLen - sizeof(response.CodeVersions.BiosVersion)- sizeof(response.CodeVersions.VersionsCount);
- if (response.CodeVersions.VersionsCount != (ptVerTypeCount/sizeof(AMT_VERSION_TYPE)))
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
-
- for (i = 0; i < (response.CodeVersions.VersionsCount); i ++)
- {
- len = response.CodeVersions.Versions[i].Description.Length;
-
- if (len > UNICODE_STRING_LEN)
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
-
- len = response.CodeVersions.Versions[i].Version.Length;
- if (response.CodeVersions.Versions[i].Version.String[len] != '\0' ||
- (len != strlen((CHAR *)(response.CodeVersions.Versions[i].Version.String))))
- {
- status = AMT_STATUS_INTERNAL_ERROR;
- break;
- }
- }
- } while (0);
-
- return status;
-}
-
-/*
-* GetVersions response message PTHI command
-* Arguments:
-* response - reference to the CODE_VERSIONS struct
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* AMT_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::GetCodeVersions(CODE_VERSIONS &codeVersions)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_CODE_VERSION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_CODE_VERSION_HEADER), sizeof(GET_CODE_VERSION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, CODE_VERSIONS_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CODE_VERSIONS_RESPONSE *tmp_response = (CFG_GET_CODE_VERSIONS_RESPONSE *)readBuffer;
- status = _verifyCodeVersions(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- memcpy(&codeVersions, &(tmp_response->CodeVersions), sizeof(CODE_VERSIONS));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningMode Host interface command
-* Arguments:
-* mode - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
-
- mode = tmp_response->ProvisioningMode;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-AMT_STATUS PTHICommand::GetProvisioningMode(CFG_PROVISIONING_MODE &mode, AMT_BOOLEAN &legacy)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_MODE_HEADER), sizeof(GET_PROVISIONING_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_MODE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_MODE_RESPONSE *)readBuffer;
-
- mode = tmp_response->ProvisioningMode;
- legacy = tmp_response->LegacyMode;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningState Host interface command
-* Arguments:
-* state - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningState(AMT_PROVISIONING_STATE &state)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_STATE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_STATE_HEADER), sizeof(GET_PROVISIONING_STATE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, PROVISIONING_STATE_RESPONSE, sizeof(CFG_GET_PROVISIONING_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PROVISIONING_STATE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_STATE_RESPONSE *)readBuffer;
-
- state = tmp_response->ProvisioningState;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetFeatureState Host interface command
-* Arguments:
-* requestID Indicates what feature status to query:
-* 0 Redirection Sessions Status
-* 1 System Defense Status
-* 2 WebUI Status
-* requestStatus The requested feature state(the size depand on the requestID).(OUT)
-*
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (&requestStatus)[2])
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_FEATURES_STATE_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &GET_FEATURES_STATE_HEADER, sizeof(GET_FEATURES_STATE_HEADER));
- memcpy(command + sizeof(GET_FEATURES_STATE_HEADER), &(requestID), sizeof(UINT32));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_FEATURES_STATE_RESPONSE, sizeof(CFG_GET_FEATURES_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_FEATURES_STATE_RESPONSE *tmp_response = (CFG_GET_FEATURES_STATE_RESPONSE *)readBuffer;
-
- GET_FEATURES_REDIRECTION_SESSION_STATUS redirectionState;
- GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE systemDefenseState;
- GET_FEATURES_WEB_UI_STATUS_RESPONSE webUIState;
- switch (requestID)
- {
- case REDIRECTION_SESSION:
- redirectionState = tmp_response->Data.rs;
- requestStatus[0] = redirectionState.SolOpen;
- requestStatus[1] = redirectionState.IderOpen;
- break;
-
- case SYSTEM_DEFENSE:
- systemDefenseState = tmp_response->Data.sd;
- requestStatus[0] = systemDefenseState.SystemDefenseActivated;
- break;
-
- case WEB_UI:
- webUIState = tmp_response->Data.webUI;
- requestStatus[0] = webUIState.WebUiEnabled;
- break;
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetLastHostResetReason Host interface command
-* Arguments:
-* reason Indicates whether the last host reason was because of remote control operation(0)
-* or other reason(1). (OUT)
-* remoteControlTimeStamp In case the reason was due to remote control then this field
-* indicates the timestamp of when the remote control command has been executed.
-* (The timestamp is the number of seconds since 1/1/1970)
-*
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetLastHostResetReason(UINT32 &reason, UINT32 &remoteControlTimeStamp)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_LAST_HOST_RESET_REASON_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_LAST_HOST_RESET_REASON_HEADER), sizeof(GET_LAST_HOST_RESET_REASON_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAST_HOST_RESET_REASON_RESPONSE, sizeof(CFG_GET_LAST_HOST_RESET_REASON_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *tmp_response = (CFG_GET_LAST_HOST_RESET_REASON_RESPONSE *)readBuffer;
-
- reason = tmp_response->Reason;
- remoteControlTimeStamp = tmp_response->RemoteControlTimeStamp;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetCurrentPowerPolicy Host interface command
-* Arguments:
-* policyName The power policy name. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetCurrentPowerPolicy(AMT_ANSI_STRING &policyName)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_CURRENT_POWER_POLICY_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_CURRENT_POWER_POLICY_HEADER), sizeof(GET_CURRENT_POWER_POLICY_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CURRENT_POWER_POLICY_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CURRENT_POWER_POLICY_RESPONSE *tmp_response = (CFG_GET_CURRENT_POWER_POLICY_RESPONSE *)readBuffer;
- status = _verifyCurrentPowerPolicy(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- policyName.Length = tmp_response->PolicyName.Length;
- policyName.Buffer = (CHAR *)malloc(policyName.Length * sizeof(CHAR));
- if (NULL == policyName.Buffer) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else {
- memcpy(policyName.Buffer, &(tmp_response->PolicyName.Buffer),
- policyName.Length * sizeof(CHAR));
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetCurrentPowerPolicy response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_CURRENT_POWER_POLICY_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
- + response.PolicyName.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GetLanInterfaceSttings Host interface command
-* Arguments:
-* interfaceSettings The interface to get the settings for.
-* lanSettings reference to a pre allocated struct which will hold the lan settings. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS &lanSettings)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &(GET_LAN_INTERFACE_SETTINGS_HEADER), sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER));
- memcpy(command + sizeof(GET_LAN_INTERFACE_SETTINGS_HEADER),
- &(interfaceSettings), sizeof(UINT32));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_LAN_INTERFACE_SETTINGS_RESPONSE, sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *tmp_response = (CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE *)readBuffer;
-
- lanSettings.Enabled = tmp_response->Enabled;
- lanSettings.Ipv4Address = tmp_response->Ipv4Address;
- lanSettings.DhcpEnabled = tmp_response->DhcpEnabled;
- lanSettings.DhcpIpMode = tmp_response->DhcpIpMode;
- lanSettings.LinkStatus = tmp_response->LinkStatus;
- memcpy(lanSettings.MacAddress, tmp_response->MacAddress, sizeof(tmp_response->MacAddress));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/**
-* Gets the HECI driver version
-* Arguments:
-* heciVersion - pointewr to HECI_VERSION struct (out)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INVALID_PARAM - on failure
-*/
-AMT_STATUS PTHICommand::GetHeciVersion(HECI_VERSION &heciVersion)
-{
- if (PTHIClient.GetHeciVersion(heciVersion)) {
- return AMT_STATUS_SUCCESS;
- }
- return AMT_STATUS_INTERNAL_ERROR;
-}
-
-/*
-* Calls to GetSecurityParameters Host interface command
-* Arguments:
-* tlsEnabled true if AMT on TLS mode. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetTLSEnabled(AMT_BOOLEAN &tlsEnabled)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_SECURITY_PARAMETERS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_SECURITY_PARAMETERS_HEADER), sizeof(GET_SECURITY_PARAMETERS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_SECURITY_PARAMETERS_RESPONSE, sizeof(CFG_GET_SECURITY_PARAMETERS_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_SECURITY_PARAMETERS_RESPONSE *tmp_response = (CFG_GET_SECURITY_PARAMETERS_RESPONSE *)readBuffer;
-
- tlsEnabled = tmp_response->TLSEnabled;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetDNSSuffixList Host interface command
-* Arguments:
-* dnsSuffixList reference to list of DNS suffix strings. (OUT)
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetDNSSuffixList(std::list<std::string> &dnsSuffixList)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_DNS_SUFFIX_LIST_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_DNS_SUFFIX_LIST_HEADER), sizeof(GET_DNS_SUFFIX_LIST_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_DNS_SUFFIX_LIST_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_DNS_SUFFIX_LIST_RESPONSE *tmp_response = (CFG_GET_DNS_SUFFIX_LIST_RESPONSE *)readBuffer;
- status = _verifyGetDNSSuffixList(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- char *current = (char *)tmp_response->Data;
- while (current < (char *)tmp_response->Data + tmp_response->DataLength)
- {
- std::string dnsSuffix = current;
- if (dnsSuffix.length() > tmp_response->DataLength)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- if (!dnsSuffix.empty())
- {
- dnsSuffixList.push_back(dnsSuffix);
- }
- current += dnsSuffix.length() + 1;
- }
- } while (0);
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetDNSSuffixList response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_DNS_SUFFIX_LIST_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER)
- + response.DataLength))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to SetEnterpriseAccess Host interface command
-* Arguments:
-* Flags flags
-* HostIPAddress host IP address for enterprise access
-* EnterpriseAccess enterprise access mode
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_SET_ENTERPRISE_ACCESS_REQUEST);
- unsigned char command[command_size];
-
- memcpy(command, &(SET_ENTERPRISE_ACCESS_HEADER), sizeof(SET_ENTERPRISE_ACCESS_HEADER));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER), &(Flags), sizeof(UINT8));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8), HostIPAddress, sizeof(HostIPAddress));
- memcpy(command + sizeof(SET_ENTERPRISE_ACCESS_HEADER) + sizeof(UINT8) + sizeof(HostIPAddress), &(EnterpriseAccess), sizeof(UINT8));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_ENTERPRISE_ACCESS_RESPONSE, sizeof(CFG_SET_ENTERPRISE_ACCESS_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Get FW last reset reason
-* Arguments:
-* reason - last FW reason
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetFWResetReason(UINT8 &MEResetReason)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(STATE_GET_AMT_STATE_REQUEST);
- unsigned char command[command_size];
- memcpy(command, &(GET_AMT_STATE_HEADER), sizeof(GET_AMT_STATE_HEADER));
- memcpy(command + sizeof(GET_AMT_STATE_HEADER), &(AMT_UUID_LINK_STATE), sizeof(AMT_UUID));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_AMT_STATE_RESPONSE, sizeof(STATE_GET_AMT_STATE_RESPONSE));
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- STATE_GET_AMT_STATE_RESPONSE *tmp_response = (STATE_GET_AMT_STATE_RESPONSE *)readBuffer;
-
- MEResetReason = tmp_response->StateData.LastMEResetReason;
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to OpenUserInitiatedConnection Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::OpenUserInitiatedConnection()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(OPEN_USER_INITIATED_CONNECTION_HEADER), sizeof(OPEN_USER_INITIATED_CONNECTION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, OPEN_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to CloseUserInitiatedConnection Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::CloseUserInitiatedConnection()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(CLOSE_USER_INITIATED_CONNECTION_HEADER), sizeof(CLOSE_USER_INITIATED_CONNECTION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, CLOSE_USER_INITIATED_CONNECTION_RESPONSE, sizeof(CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/* Calls to GetRemoteAccessConnectionStatus Host interface command
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS &remoteAccessStatus)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER), sizeof(GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *tmp_response = (CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE *)readBuffer;
- status = _verifyRemoteAccessConnectionStatus(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- remoteAccessStatus.AmtNetworkConnectionStatus = tmp_response->AmtNetworkConnectionStatus;
- remoteAccessStatus.RemoteAccessConnectionStatus = tmp_response->RemoteAccessConnectionStatus;
- remoteAccessStatus.RemoteAccessConnectionTrigger = tmp_response->RemoteAccessConnectionTrigger;
-
- remoteAccessStatus.MpsHostname.Length = tmp_response->MpsHostname.Length;
- remoteAccessStatus.MpsHostname.Buffer = (CHAR *)malloc(remoteAccessStatus.MpsHostname.Length * sizeof(CHAR));
- if (NULL == remoteAccessStatus.MpsHostname.Buffer) {
- status = AMT_STATUS_INTERNAL_ERROR;
- } else {
- memcpy(remoteAccessStatus.MpsHostname.Buffer,
- &(tmp_response->MpsHostname.Buffer),
- tmp_response->MpsHostname.Length * sizeof(CHAR));
- }
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the GetRemoteAccessConnectionStatus response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
- if (ByteCount != (sizeof(CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE)
- - sizeof(PTHI_MESSAGE_HEADER) - sizeof(CHAR *)
- + response.MpsHostname.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GenerateRngKey Host interface command
-* Arguments:
-* None
-* Return values:
-* AMT_STATUS_SUCCESS - or AMT_STATUS_IN_PROGRESS on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GenerateRngKey()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GENERATE_RNG_SEED_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GENERATE_RNG_SEED_HEADER), sizeof(GENERATE_RNG_SEED_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GENERATE_RNG_SEED_RESPONSE, sizeof(CFG_GENERATE_RNG_SEED_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetRngSeedStatus Host interface command
-* Arguments:
-* rngStatus - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetRngSeedStatus(AMT_RNG_STATUS &rngStatus)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_RNG_SEED_STATUS_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_RNG_SEED_STATUS_HEADER), sizeof(GET_RNG_SEED_STATUS_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_RNG_SEED_STATUS_RESPONSE, sizeof(CFG_GET_RNG_SEED_STATUS_RESPONSE));
-
- CFG_GET_RNG_SEED_STATUS_RESPONSE *tmp_response = (CFG_GET_RNG_SEED_STATUS_RESPONSE *)readBuffer;
-
- rngStatus = tmp_response->RngStatus;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to ZeroTouchEnabled Host interface command
-* Arguments:
-* zeroTouchEnabled - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetZeroTouchEnabled(AMT_BOOLEAN &zeroTouchEnabled)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_ZERO_TOUCH_ENABLED_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_ZERO_TOUCH_ENABLED_HEADER), sizeof(GET_ZERO_TOUCH_ENABLED_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_ZERO_TOUCH_ENABLED_RESPONSE, sizeof(CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE));
-
- CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *tmp_response = (CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE *)readBuffer;
-
- zeroTouchEnabled = tmp_response->ZeroTouchEnabled;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to GetProvisioningTlsMode Host interface command
-* Arguments:
-* provisioningTlsMode - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE &provisioningTlsMode)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PROVISIONING_TLS_MODE_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PROVISIONING_TLS_MODE_HEADER), sizeof(GET_PROVISIONING_TLS_MODE_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PROVISIONING_TLS_MODE_RESPONSE, sizeof(CFG_GET_PROVISIONING_TLS_MODE_RESPONSE));
-
- CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *tmp_response = (CFG_GET_PROVISIONING_TLS_MODE_RESPONSE *)readBuffer;
-
- provisioningTlsMode = tmp_response->ProvisioningTlsMode;
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to StartConfiguration Host interface command
-* Arguments:
-* None
-* Return values:
-* AMT_STATUS_SUCCESS - or AMT_STATUS_CERTIFICATE_NOT_READY on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::StartConfiguration()
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(START_CONFIGURATION_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(START_CONFIGURATION_HEADER), sizeof(START_CONFIGURATION_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, START_CONFIGURATION_RESPONSE, sizeof(CFG_START_CONFIGURATION_RESPONSE));
-
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to SetProvisioningServerOTP Host interface command
-* Arguments:
-* passwordOTP AMT_ANSI_STRING structure of OTP password
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP)
-{
- if (NULL == passwordOTP.Buffer)
- {
- return PTSDK_STATUS_INVALID_PARAM;
- }
-
- UINT8 *readBuffer = NULL;
- UINT32 msgLength = sizeof(passwordOTP.Length) + (passwordOTP.Length * sizeof(CHAR));
- PTHI_MESSAGE_HEADER SET_PROVISIONING_SERVER_OTP_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_PROVISIONING_SERVER_OTP_REQUEST}}, msgLength
- };
-
- const UINT32 command_size = sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + msgLength;
- unsigned char *command;
- command = (unsigned char *)malloc(command_size);
- if (NULL == command)
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- memcpy(command, &SET_PROVISIONING_SERVER_OTP_HEADER, sizeof(SET_PROVISIONING_SERVER_OTP_HEADER));
- memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER), &(passwordOTP.Length), sizeof(passwordOTP.Length));
- memcpy(command + sizeof(SET_PROVISIONING_SERVER_OTP_HEADER) + sizeof(passwordOTP.Length),
- passwordOTP.Buffer, passwordOTP.Length);
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_PROVISIONING_SERVER_OTP_RESPONSE, sizeof(CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE));
-
- if (NULL != command)
- {
- free(command);
- }
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to SetDnsSuffix Host interface command
-* Arguments:
-* dnsSuffix AMT_ANSI_STRING structure of DNS suffix
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::SetDnsSuffix(AMT_ANSI_STRING dnsSuffix)
-{
- if (NULL == dnsSuffix.Buffer)
- {
- return PTSDK_STATUS_INVALID_PARAM;
- }
-
- UINT8 *readBuffer = NULL;
- UINT32 msgLength = sizeof(dnsSuffix.Length) + (dnsSuffix.Length * sizeof(CHAR));
- PTHI_MESSAGE_HEADER SET_DNS_SUFFIX_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_DNS_SUFFIX_REQUEST}}, msgLength
- };
-
- const UINT32 command_size = sizeof(SET_DNS_SUFFIX_HEADER) + msgLength;
- unsigned char *command;
- command = (unsigned char *)malloc(command_size);
- if (NULL == command)
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- memcpy(command, &SET_DNS_SUFFIX_HEADER, sizeof(SET_DNS_SUFFIX_HEADER));
- memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER), &(dnsSuffix.Length), sizeof(dnsSuffix.Length));
- memcpy(command + sizeof(SET_DNS_SUFFIX_HEADER) + sizeof(dnsSuffix.Length), dnsSuffix.Buffer, dnsSuffix.Length);
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, SET_DNS_SUFFIX_RESPONSE, sizeof(CFG_SET_DNS_SUFFIX_RESPONSE));
-
- if (NULL != command)
- {
- free(command);
- }
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Calls to EnumerateHashHandles Host interface command
-* Arguments:
-* hashHandles - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::EnumerateHashHandles(AMT_HASH_HANDLES &hashHandles)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(ENUMERATE_HASH_HANDLES_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(ENUMERATE_HASH_HANDLES_HEADER), sizeof(ENUMERATE_HASH_HANDLES_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, ENUMERATE_HASH_HANDLES_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_HASH_HANDLES_RESPONSE *tmp_response = (CFG_GET_HASH_HANDLES_RESPONSE *)readBuffer;
- status = _verifyHashHandles(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- memset(hashHandles.Handles, 0, sizeof(UINT32) * CERT_HASH_MAX_NUMBER);
- hashHandles.Length = tmp_response->HashHandles.Length;
- if (CERT_HASH_MAX_NUMBER < hashHandles.Length)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
-
- memcpy(hashHandles.Handles, tmp_response->HashHandles.Handles, sizeof(UINT32) * hashHandles.Length);
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-
-/*
-* Confirms the correctness of the EnumerateHashHandles response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- sizeof(AMT_STATUS) + sizeof(response.HashHandles.Length) + (sizeof(UINT32) * response.HashHandles.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-
-/*
-* Calls to GetCertificateHashEntry Host interface command
-* Arguments:
-* passwordOTP AMT_ANSI_STRING structure of DNS suffix
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY &hashEntry)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(CFG_GET_CERTHASH_ENTRY_REQUEST);
- unsigned char command[command_size];
- memcpy(command, &(GET_CERTHASH_ENTRY_HEADER), sizeof(GET_CERTHASH_ENTRY_HEADER));
- memcpy(command + sizeof(GET_CERTHASH_ENTRY_HEADER), &(hashHandle), sizeof(hashHandle));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_CERTHASH_ENTRY_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_CERTHASH_ENTRY_RESPONSE *tmp_response = (CFG_GET_CERTHASH_ENTRY_RESPONSE *)readBuffer;
- status = _verifyGetCertificateHashEntry(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- hashEntry.IsActive = tmp_response->Hash.IsActive;
- hashEntry.IsDefault = tmp_response->Hash.IsDefault;
- hashEntry.Name.Length = tmp_response->Hash.Name.Length;
- hashEntry.HashAlgorithm = tmp_response->Hash.HashAlgorithm;
- memcpy(hashEntry.CertificateHash, tmp_response->Hash.CertificateHash, sizeof(tmp_response->Hash.CertificateHash));
- hashEntry.Name.Buffer = (CHAR *)malloc(hashEntry.Name.Length * sizeof(CHAR));
- if (NULL == hashEntry.Name.Buffer)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- memcpy(hashEntry.Name.Buffer, &(tmp_response->Hash.Name.Buffer), hashEntry.Name.Length * sizeof(CHAR));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-/*
-* Confirms the correctness of the GetCertificateHashEntry response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- (sizeof(CFG_GET_CERTHASH_ENTRY_RESPONSE) - sizeof(PTHI_MESSAGE_HEADER)
- - sizeof(CHAR *) + response.Hash.Name.Length))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-/*
-* Calls to GetDnsSuffix Host interface command
-* Arguments:
-* dnsSuffix - reference to the pre-allocated structure
-* which will hold the result
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* appropriate error value defined in StatusCodeDefinitions.h - on failure
-*/
-AMT_STATUS PTHICommand::GetDnsSuffix(AMT_ANSI_STRING &dnsSuffix)
-{
- UINT8 *readBuffer = NULL;
- const UINT32 command_size = sizeof(GET_PKI_FQDN_SUFFIX_HEADER);
- unsigned char command[command_size];
- memcpy(command, &(GET_PKI_FQDN_SUFFIX_HEADER), sizeof(GET_PKI_FQDN_SUFFIX_HEADER));
-
- AMT_STATUS status = _call(command, command_size, &readBuffer, GET_PKI_FQDN_SUFFIX_RESPONSE, 0);
- do {
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
- CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *tmp_response = (CFG_GET_PKI_FQDN_SUFFIX_RESPONSE *)readBuffer;
- status = _verifyGetDnsSuffix(*tmp_response);
- if (status != AMT_STATUS_SUCCESS)
- {
- break;
- }
-
- dnsSuffix.Length = tmp_response->Suffix.Length;
- dnsSuffix.Buffer = (CHAR *)malloc(dnsSuffix.Length * sizeof(CHAR));
- if (NULL == dnsSuffix.Buffer)
- {
- status = PTSDK_STATUS_INTERNAL_ERROR;
- break;
- }
- memcpy(dnsSuffix.Buffer, &(tmp_response->Suffix.Buffer), dnsSuffix.Length * sizeof(CHAR));
-
- } while (0);
- if (readBuffer != NULL)
- {
- free(readBuffer);
- }
- return status;
-}
-/*
-* Confirms the correctness of the GetDnsSuffix response message
-* Arguments:
-* response - reference to the response message
-* Return values:
-* AMT_STATUS_SUCCESS - on success
-* PTSDK_STATUS_INTERNAL_ERROR - on failure
-*/
-AMT_STATUS PTHICommand::_verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE &response)
-{
- ULONG ByteCount = response.Header.Header.Length;
-
- if (ByteCount !=
- sizeof(AMT_STATUS) + sizeof(response.Suffix.Length) + response.Suffix.Length * sizeof(CHAR))
- {
- return PTSDK_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
diff --git a/usr/src/cmd/lms/heci/PTHICommand.h b/usr/src/cmd/lms/heci/PTHICommand.h
deleted file mode 100644
index 66f2e57f51..0000000000
--- a/usr/src/cmd/lms/heci/PTHICommand.h
+++ /dev/null
@@ -1,770 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: PTHICommand.h
-//
-// Contents: header file of PTHICommand class
-//
-//----------------------------------------------------------------------------
-#ifndef __PTHI_COMMAND_H__
-#define __PTHI_COMMAND_H__
-
-#include "HECIUnix.h"
-#include "StatusCodeDefinitions.h"
-#include <list>
-#include <string>
-
-#define CERT_HASH_MAX_LENGTH 64
-#define CERT_HASH_MAX_NUMBER 23
-#define NET_TLS_CERT_PKI_MAX_SERIAL_NUMS 3
-#define NET_TLS_CERT_PKI_MAX_SERIAL_NUM_LENGTH 16
-#define MPS_HOSTNAME_LENGTH 256
-
-/*
-* Constants
-*/
-
-static const UINT32 IDER_LOG_ENTRIES = 16;
-
-const UINT8 MAJOR_VERSION = 1;
-const UINT8 MINOR_VERSION = 1;
-const UINT8 AMT_MAJOR_VERSION = 1;
-const UINT8 AMT_MINOR_VERSION = 1;
-
-typedef enum _CFG_PROVISIONING_MODE
-{
- CFG_PROVISIONING_MODE_NONE = 0,
- CFG_PROVISIONING_MODE_ENTERPRISE,
- CFG_PROVISIONING_MODE_SMALL_BUSINESS,
- CFG_PROVISIONING_MODE_REMOTE_ASSISTANCE
-} CFG_PROVISIONING_MODE;
-
-typedef enum _AMT_PROVISIONING_STATE
-{
- PROVISIONING_STATE_PRE = 0,
- PROVISIONING_STATE_IN = 1,
- PROVISIONING_STATE_POST = 2
-} AMT_PROVISIONING_STATE;
-
-typedef enum _AMT_FEATURE_STATE_REQUEST
-{
- REDIRECTION_SESSION = 0,
- SYSTEM_DEFENSE = 1,
- WEB_UI = 2
-} AMT_FEATURE_STATE_REQUEST;
-
-typedef enum _AMT_LAST_HOST_RESET_REASON
-{
- RemoteControl = 0,
- Other = 1
-} AMT_LAST_HOST_RESET_REASON;
-
-typedef enum _AMT_INTERFACE_INDEX
-{
- WIRED = 0,
- WIRELESS = 1
-} AMT_INTERFACE_INDEX;
-
-typedef enum _AMT_DHCP_IP_ADDRESS
-{
- ACTIVE = 1,
- PASSIVE = 2
-} AMT_DHCP_IP_MODE;
-
-typedef UINT32 CFG_IPv4_ADDRESS;
-
-static const UINT32 BIOS_VERSION_LEN = 65;
-static const UINT32 VERSIONS_NUMBER = 50;
-static const UINT32 UNICODE_STRING_LEN = 20;
-
-typedef enum _AMT_PROVISIONING_TLS_MODE
-{
- NOT_READY = 0,
- PSK = 1,
- PKI = 2
-} AMT_PROVISIONING_TLS_MODE;
-
-typedef enum _AMT_RNG_STATUS
-{
- RNG_STATUS_EXIST = 0,
- RNG_STATUS_IN_PROGRESS = 1,
- RNG_STATUS_NOT_EXIST = 2
-} AMT_RNG_STATUS;
-
-#pragma pack(1)
-
-typedef struct _AMT_UNICODE_STRING
-{
- UINT16 Length;
- UINT8 String[UNICODE_STRING_LEN];
-} AMT_UNICODE_STRING;
-
-typedef struct _AMT_VERSION_TYPE
-{
- AMT_UNICODE_STRING Description;
- AMT_UNICODE_STRING Version;
-} AMT_VERSION_TYPE;
-
-typedef struct _PTHI_VERSION
-{
- UINT8 MajorNumber;
- UINT8 MinorNumber;
-} PTHI_VERSION;
-
-typedef struct _CODE_VERSIONS
-{
- UINT8 BiosVersion[BIOS_VERSION_LEN];
- UINT32 VersionsCount;
- AMT_VERSION_TYPE Versions[VERSIONS_NUMBER];
-} CODE_VERSIONS;
-
-typedef struct _COMMAND_FMT
-{
- union
- {
- UINT32 val;
- struct
- {
- UINT32 Operation : 23;
- UINT32 IsResponse : 1;
- UINT32 Class : 8;
- } fields;
- } cmd;
-
-} COMMAND_FMT;
-
-typedef struct _AMT_ANSI_STRING
-{
- UINT16 Length;
- CHAR *Buffer;
-} AMT_ANSI_STRING;
-
-typedef struct _PTHI_MESSAGE_HEADER
-{
- PTHI_VERSION Version;
- UINT16 Reserved;
- COMMAND_FMT Command;
- UINT32 Length;
-} PTHI_MESSAGE_HEADER;
-
-typedef struct _PTHI_RESPONSE_MESSAGE_HEADER
-{
- PTHI_MESSAGE_HEADER Header;
- AMT_STATUS Status;
-} PTHI_RESPONSE_MESSAGE_HEADER;
-
-typedef struct _CFG_GET_CODE_VERSIONS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- CODE_VERSIONS CodeVersions;
-} CFG_GET_CODE_VERSIONS_RESPONSE;
-
-typedef struct _CFG_GET_PROVISIONING_MODE_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- CFG_PROVISIONING_MODE ProvisioningMode;
- AMT_BOOLEAN LegacyMode;
-} CFG_GET_PROVISIONING_MODE_RESPONSE;
-
-typedef struct _CFG_GET_PROVISIONING_STATE_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_PROVISIONING_STATE ProvisioningState;
-} CFG_GET_PROVISIONING_STATE_RESPONSE;
-
-typedef struct _CFG_GET_FEATURES_STATE_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
- UINT32 RequestID;
-} CFG_GET_FEATURES_STATE_REQUEST;
-
-typedef struct _GET_FEATURES_REDIRECTION_SESSION_STATUS
-{
- AMT_BOOLEAN IderOpen;
- AMT_BOOLEAN SolOpen;
- AMT_BOOLEAN Reserved;
-} GET_FEATURES_REDIRECTION_SESSION_STATUS;
-
-typedef struct _GET_FEATURES_SYSTEM_DEFENSE_STATE_RESPONSE
-{
- AMT_BOOLEAN SystemDefenseActivated;
-} GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE;
-
-typedef struct _GET_FEATURES_WEB_UI_STATE_RESPONSE
-{
- AMT_BOOLEAN WebUiEnabled;
-} GET_FEATURES_WEB_UI_STATUS_RESPONSE;
-
-typedef union _FEATURES_STATUS_DATA
-{
- GET_FEATURES_REDIRECTION_SESSION_STATUS rs;
- GET_FEATURES_SYSTEM_DEFENSE_STATUS_RESPONSE sd;
- GET_FEATURES_WEB_UI_STATUS_RESPONSE webUI;
-} FEATURES_STATUS_DATA;
-
-typedef struct _CFG_GET_FEATURES_STATE_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- UINT32 RequestID;
- FEATURES_STATUS_DATA Data;
-} CFG_GET_FEATURES_STATE_RESPONSE;
-
-typedef struct _CFG_GET_CURRENT_POWER_POLICY_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_GET_CURRENT_POWER_POLICY_REQUEST;
-
-typedef struct _CFG_GET_CURRENT_POWER_POLICY_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_ANSI_STRING PolicyName;
-} CFG_GET_CURRENT_POWER_POLICY_RESPONSE;
-
-typedef struct _CFG_GET_LAST_HOST_RESET_REASON_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_GET_LAST_HOST_RESET_REASON_REQUEST;
-
-typedef struct _CFG_GET_LAST_HOST_RESET_REASON_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- UINT32 Reason;
- UINT32 RemoteControlTimeStamp;
-} CFG_GET_LAST_HOST_RESET_REASON_RESPONSE;
-
-typedef struct _LAN_SETTINGS
-{
- AMT_BOOLEAN Enabled;
- CFG_IPv4_ADDRESS Ipv4Address;
- AMT_BOOLEAN DhcpEnabled;
- UINT8 DhcpIpMode;
- UINT8 LinkStatus;
- UINT8 MacAddress[6];
-} LAN_SETTINGS;
-
-typedef struct _CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
- UINT32 InterfaceIndex;
-} CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST;
-
-typedef struct _CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_BOOLEAN Enabled;
- CFG_IPv4_ADDRESS Ipv4Address;
- AMT_BOOLEAN DhcpEnabled;
- UINT8 DhcpIpMode;
- UINT8 LinkStatus;
- UINT8 MacAddress[6];
-} CFG_GET_LAN_INTERFACE_SETTINGS_RESPONSE;
-
-typedef struct _CFG_GET_SECURITY_PARAMETERS_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_GET_SECURITY_PARAMETERS_REQUEST;
-
-typedef struct _CFG_GET_SECURITY_PARAMETERS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_BOOLEAN EnterpriseMode;
- AMT_BOOLEAN TLSEnabled;
- AMT_BOOLEAN HWCryptoEnabled;
- AMT_PROVISIONING_STATE ProvisioningState;
- AMT_BOOLEAN NetworkInterfaceEnabled;
- AMT_BOOLEAN SOLEnabled;
- AMT_BOOLEAN IDEREnabled;
- AMT_BOOLEAN FWUpdateEnabled;
- AMT_BOOLEAN LinkIsUp;
- AMT_BOOLEAN Reserved[8];
-} CFG_GET_SECURITY_PARAMETERS_RESPONSE;
-
-typedef struct _CFG_GET_DNS_SUFFIX_LIST_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_GET_DNS_SUFFIX_LIST_REQUEST;
-
-typedef struct _CFG_GET_DNS_SUFFIX_LIST_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- UINT16 DataLength;
- UINT8 Data[0];
-} CFG_GET_DNS_SUFFIX_LIST_RESPONSE;
-
-/**
- * CFG_SET_ENTERPRISE_ACCESS_REQUEST
- *
- * Flags Bit 0 - If this bit is set then HostIPAddress is IPv6, otherwise HostIPAddress is IPv4 address.
- * Bits 1..7 - Reserved, should be zero.
- * HostIPAddress IPv4 / IPv6 address
- * EnterpriseAccess 1 if LMS has access to enterprise network, otherwise 0.
- */
-typedef struct _CFG_SET_ENTERPRISE_ACCESS_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
- UINT8 Flags;
- UINT8 HostIPAddress[16];
- UINT8 EnterpriseAccess;
-} CFG_SET_ENTERPRISE_ACCESS_REQUEST;
-
-typedef struct _CFG_SET_ENTERPRISE_ACCESS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_SET_ENTERPRISE_ACCESS_RESPONSE;
-
-typedef struct _CFG_OPEN_USER_INITIATED_CONNECTION_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_OPEN_USER_INITIATED_CONNECTION_REQUEST;
-
-typedef struct _CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_OPEN_USER_INITIATED_CONNECTION_RESPONSE;
-
-typedef struct _CFG_CLOSE_USER_INITIATED_CONNECTION_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_CLOSE_USER_INITIATED_CONNECTION_REQUEST;
-
-typedef struct _CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_CLOSE_USER_INITIATED_CONNECTION_RESPONSE;
-
-typedef enum
-{
- AMT_NETWORK_CONNECTION_DIRECT = 0,
- AMT_NETWORK_CONNECTION_VPN,
- AMT_NETWORK_CONNECTION_OUTSIDE_ENTERPRISE
-} AMT_NETWORK_CONNECTION_STATUS;
-
-typedef enum
-{
- REMOTE_ACCESS_CONNECTION_STATUS_NOT_CONNECTED = 0,
- REMOTE_ACCESS_CONNECTION_STATUS_CONNECTING,
- REMOTE_ACCESS_CONNECTION_STATUS_CONNECTED
-} REMOTE_ACCESS_CONNECTION_STATUS;
-
-typedef enum
-{
- REMOTE_ACCESS_CONNECTION_TRIGGER_USER_INITIATED = 0,
- REMOTE_ACCESS_CONNECTION_TRIGGER_ALERT,
- REMOTE_ACCESS_CONNECTION_TRIGGER_PROVISIONING,
- REMOTE_ACCESS_CONNECTION_TRIGGER_PERIODIC
-} REMOTE_ACCESS_CONNECTION_TRIGGER;
-
-typedef struct _CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
-} CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST;
-
-typedef struct _CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_NETWORK_CONNECTION_STATUS AmtNetworkConnectionStatus;
- REMOTE_ACCESS_CONNECTION_STATUS RemoteAccessConnectionStatus;
- REMOTE_ACCESS_CONNECTION_TRIGGER RemoteAccessConnectionTrigger;
- AMT_ANSI_STRING MpsHostname;
-} CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE;
-
-typedef struct _REMOTE_ACCESS_STATUS
-{
- AMT_NETWORK_CONNECTION_STATUS AmtNetworkConnectionStatus;
- REMOTE_ACCESS_CONNECTION_STATUS RemoteAccessConnectionStatus;
- REMOTE_ACCESS_CONNECTION_TRIGGER RemoteAccessConnectionTrigger;
- AMT_ANSI_STRING MpsHostname;
-} REMOTE_ACCESS_STATUS;
-
-
-typedef UINT8 AMT_UUID[16];
-
-const AMT_UUID AMT_UUID_LINK_STATE =
- {0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01};
-
-typedef struct _STATE_DATA
-{
- UINT8 LinkStatus; // (0 - down; 1 - up)
- UINT8 HardSKU;
- UINT8 CryptoFuse; // (0 - disabled; 1 - enabled)
- UINT8 FlashProtaction; // (0 - disabled; 1 - enabled)
- UINT8 LastMEResetReason;
-} STATE_DATA;
-
-typedef struct _STATE_GET_AMT_STATE_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
- AMT_UUID StateVariableIdentifier;
-} STATE_GET_AMT_STATE_REQUEST;
-
-typedef struct _STATE_GET_AMT_STATE_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_UUID StateDataIdentifier;
- UINT32 ByteCount;
- STATE_DATA StateData;
-} STATE_GET_AMT_STATE_RESPONSE;
-
-
-typedef struct _AMT_HASH_HANDLES
-{
- UINT32 Length;
- UINT32 Handles[CERT_HASH_MAX_NUMBER];
-} AMT_HASH_HANDLES;
-
-typedef struct _CERTHASH_ENTRY
-{
- AMT_BOOLEAN IsDefault;
- AMT_BOOLEAN IsActive;
- UINT8 CertificateHash[CERT_HASH_MAX_LENGTH];
- UINT8 HashAlgorithm;
- AMT_ANSI_STRING Name;
-} CERTHASH_ENTRY;
-
-typedef enum
-{
- CERT_HASH_ALGORITHM_MD5 = 0, // 16 bytes
- CERT_HASH_ALGORITHM_SHA1, // 20 bytes
- CERT_HASH_ALGORITHM_SHA256, // 32 bytes
- CERT_HASH_ALGORITHM_SHA512 // 64 bytes
-} CERT_HASH_ALGORITHM;
-
-typedef struct
-{
- UINT16 Year;
- UINT16 Month;
- UINT16 DayOfWeek;
- UINT16 Day;
- UINT16 Hour;
- UINT16 Minute;
- UINT16 Second;
-} TIME_DATE;
-
-typedef struct _AMT_PROV_AUDIT_RECORD
-{
- UINT8 ProvisioningTLSMode;
- AMT_BOOLEAN SecureDNS;
- AMT_BOOLEAN HostInitiated;
- CERT_HASH_ALGORITHM SelectedHashType;
- UINT8 SelectedHashData[CERT_HASH_MAX_LENGTH];
- UINT8 CaCertificateSerials[NET_TLS_CERT_PKI_MAX_SERIAL_NUMS*NET_TLS_CERT_PKI_MAX_SERIAL_NUM_LENGTH];
- AMT_BOOLEAN AdditionalCaSerialNums;
- AMT_BOOLEAN IsOemDefault;
- AMT_BOOLEAN IsTimeValid;
- UINT32 ProvServerIP;
- TIME_DATE TlsStartTime;
- AMT_ANSI_STRING ProvServerFQDN;
-} AMT_PROV_AUDIT_RECORD;
-
-typedef struct _CFG_GENERATE_RNG_SEED_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_GENERATE_RNG_SEED_RESPONSE;
-
-typedef struct _CFG_GET_RNG_SEED_STATUS_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_RNG_STATUS RngStatus;
-} CFG_GET_RNG_SEED_STATUS_RESPONSE;
-
-typedef struct _CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_BOOLEAN ZeroTouchEnabled;
-} CFG_GET_ZERO_TOUCH_ENABLED_RESPONSE;
-
-typedef struct _CFG_GET_PROVISIONING_TLS_MODE_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_PROVISIONING_TLS_MODE ProvisioningTlsMode;
-} CFG_GET_PROVISIONING_TLS_MODE_RESPONSE;
-
-typedef struct _CFG_START_CONFIGURATION_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_START_CONFIGURATION_RESPONSE;
-
-typedef struct _CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_SET_PROVISIONING_SERVER_OTP_RESPONSE;
-
-typedef struct _CFG_SET_DNS_SUFFIX_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
-} CFG_SET_DNS_SUFFIX_RESPONSE;
-
-typedef struct _CFG_GET_HASH_HANDLES_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_HASH_HANDLES HashHandles;
-} CFG_GET_HASH_HANDLES_RESPONSE;
-
-typedef struct _CFG_GET_CERTHASH_ENTRY_REQUEST
-{
- PTHI_MESSAGE_HEADER Header;
- UINT32 HashHandle;
-} CFG_GET_CERTHASH_ENTRY_REQUEST;
-
-typedef struct _CFG_GET_CERTHASH_ENTRY_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- CERTHASH_ENTRY Hash;
-} CFG_GET_CERTHASH_ENTRY_RESPONSE;
-
-typedef struct _CFG_GET_PKI_FQDN_SUFFIX_RESPONSE
-{
- PTHI_RESPONSE_MESSAGE_HEADER Header;
- AMT_ANSI_STRING Suffix;
-} CFG_GET_PKI_FQDN_SUFFIX_RESPONSE;
-
-#pragma pack()
-
-class PTHICommand
-{
-public:
- PTHICommand(bool verbose = false, unsigned long sendTimeout = 2000);
- ~PTHICommand();
-
- AMT_STATUS GetCodeVersions(CODE_VERSIONS &codeVersions);
- AMT_STATUS GetProvisioningMode(CFG_PROVISIONING_MODE &provisioningMode);
- AMT_STATUS GetProvisioningMode(CFG_PROVISIONING_MODE &provisioningMode, AMT_BOOLEAN &legacy);
- AMT_STATUS GetProvisioningState(AMT_PROVISIONING_STATE &state);
- AMT_STATUS GetFeaturesState(UINT32 requestID, AMT_BOOLEAN (&requestStatus)[2]);
- AMT_STATUS GetLastHostResetReason(UINT32 &Reason, UINT32 &RemoteControlTimeStamp);
- AMT_STATUS GetCurrentPowerPolicy(AMT_ANSI_STRING &policyName);
- AMT_STATUS GetLanInterfaceSettings(UINT32 interfaceSettings, LAN_SETTINGS &lanSettings);
- AMT_STATUS GetHeciVersion(HECI_VERSION &hecVersion);
- AMT_STATUS GetTLSEnabled(AMT_BOOLEAN &tlsEnabled);
- AMT_STATUS GetDNSSuffixList(std::list<std::string> &dnsSuffixList);
- AMT_STATUS SetEnterpriseAccess(UINT8 Flags, UINT8 HostIPAddress[16], UINT8 EnterpriseAccess);
- AMT_STATUS GetFWResetReason(UINT8 &MEResetReason);
- AMT_STATUS OpenUserInitiatedConnection();
- AMT_STATUS CloseUserInitiatedConnection();
- AMT_STATUS GetRemoteAccessConnectionStatus(REMOTE_ACCESS_STATUS &remoteAccessStatus);
- AMT_STATUS GenerateRngKey();
- AMT_STATUS GetRngSeedStatus(AMT_RNG_STATUS &rngStatus);
- AMT_STATUS GetZeroTouchEnabled(AMT_BOOLEAN &zeroTouchEnabled);
- AMT_STATUS GetProvisioningTlsMode(AMT_PROVISIONING_TLS_MODE &provisioningTlsMode);
- AMT_STATUS StartConfiguration();
- AMT_STATUS SetProvisioningServerOTP(AMT_ANSI_STRING passwordOTP);
- AMT_STATUS SetDnsSuffix(AMT_ANSI_STRING dnsSuffix);
- AMT_STATUS EnumerateHashHandles(AMT_HASH_HANDLES &hashHandles);
- AMT_STATUS GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY &hashEntry);
- AMT_STATUS GetDnsSuffix(AMT_ANSI_STRING &dnsSuffix);
-
- HECILinux PTHIClient;
-
-private:
- AMT_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **readBuffer, UINT32 rcmd, unsigned int expSize = 0);
- AMT_STATUS _verifyResponseHeader(const UINT32 command, const PTHI_MESSAGE_HEADER &response_header, UINT32 response_size);
- AMT_STATUS _verifyCodeVersions(const CFG_GET_CODE_VERSIONS_RESPONSE &response);
- AMT_STATUS _verifyCurrentPowerPolicy(const CFG_GET_CURRENT_POWER_POLICY_RESPONSE &response);
- AMT_STATUS _verifyGetDNSSuffixList(const CFG_GET_DNS_SUFFIX_LIST_RESPONSE &response);
- AMT_STATUS _verifyRemoteAccessConnectionStatus(const CFG_GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE &response);
- AMT_STATUS _verifyHashHandles(const CFG_GET_HASH_HANDLES_RESPONSE &response);
- AMT_STATUS _verifyGetCertificateHashEntry(const CFG_GET_CERTHASH_ENTRY_RESPONSE &response);
- AMT_STATUS _verifyGetDnsSuffix(const CFG_GET_PKI_FQDN_SUFFIX_RESPONSE &response);
-
- unsigned long m_sendTimeout;
-};
-
-/*
-* Constants
-*/
-
-
-const UINT32 CODE_VERSIONS_REQUEST = 0x0400001A;
-const UINT32 CODE_VERSIONS_RESPONSE = 0x0480001A;
-
-const PTHI_MESSAGE_HEADER GET_CODE_VERSION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{CODE_VERSIONS_REQUEST}}, 0
-};
-
-const UINT32 PROVISIONING_MODE_REQUEST = 0x04000008;
-const UINT32 PROVISIONING_MODE_RESPONSE = 0x04800008;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_MODE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{PROVISIONING_MODE_REQUEST}}, 0
-};
-
-const UINT32 PROVISIONING_STATE_REQUEST = 0x04000011;
-const UINT32 PROVISIONING_STATE_RESPONSE = 0x04800011;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{PROVISIONING_STATE_REQUEST}}, 0
-};
-
-const UINT32 GET_FEATURES_STATE_REQUEST = 0x04000049;
-const UINT32 GET_FEATURES_STATE_RESPONSE = 0x04800049;
-
-const PTHI_MESSAGE_HEADER GET_FEATURES_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_FEATURES_STATE_REQUEST}}, (sizeof(CFG_GET_FEATURES_STATE_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 GET_CURRENT_POWER_POLICY_REQUEST = 0x04000047;
-const UINT32 GET_CURRENT_POWER_POLICY_RESPONSE = 0x04800047;
-
-const PTHI_MESSAGE_HEADER GET_CURRENT_POWER_POLICY_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_CURRENT_POWER_POLICY_REQUEST}}, 0
-};
-
-const UINT32 GET_LAST_HOST_RESET_REASON_REQUEST = 0x0400004A;
-const UINT32 GET_LAST_HOST_RESET_REASON_RESPONSE = 0x0480004A;
-
-const PTHI_MESSAGE_HEADER GET_LAST_HOST_RESET_REASON_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_LAST_HOST_RESET_REASON_REQUEST}}, 0
-};
-
-const UINT32 GET_LAN_INTERFACE_SETTINGS_REQUEST = 0x04000048;
-const UINT32 GET_LAN_INTERFACE_SETTINGS_RESPONSE = 0x04800048;
-
-const PTHI_MESSAGE_HEADER GET_LAN_INTERFACE_SETTINGS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_LAN_INTERFACE_SETTINGS_REQUEST}}, (sizeof(CFG_GET_LAN_INTERFACE_SETTINGS_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 GET_SECURITY_PARAMETERS_REQUEST =0x0400001B;
-const UINT32 GET_SECURITY_PARAMETERS_RESPONSE =0x0480001B;
-
-const PTHI_MESSAGE_HEADER GET_SECURITY_PARAMETERS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_SECURITY_PARAMETERS_REQUEST}}, 0
-};
-
-const UINT32 GET_DNS_SUFFIX_LIST_REQUEST = 0x0400003E;
-const UINT32 GET_DNS_SUFFIX_LIST_RESPONSE = 0x0480003E;
-
-const PTHI_MESSAGE_HEADER GET_DNS_SUFFIX_LIST_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_DNS_SUFFIX_LIST_REQUEST}}, 0
-};
-
-const UINT32 SET_ENTERPRISE_ACCESS_REQUEST = 0x0400003F;
-const UINT32 SET_ENTERPRISE_ACCESS_RESPONSE = 0x0480003F;
-
-const PTHI_MESSAGE_HEADER SET_ENTERPRISE_ACCESS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{SET_ENTERPRISE_ACCESS_REQUEST}}, (sizeof(CFG_SET_ENTERPRISE_ACCESS_REQUEST) - sizeof(PTHI_MESSAGE_HEADER))
-};
-
-const UINT32 OPEN_USER_INITIATED_CONNECTION_REQUEST = 0x04000044;
-const UINT32 OPEN_USER_INITIATED_CONNECTION_RESPONSE = 0x04800044;
-
-const PTHI_MESSAGE_HEADER OPEN_USER_INITIATED_CONNECTION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{OPEN_USER_INITIATED_CONNECTION_REQUEST}}, 0
-};
-
-const UINT32 CLOSE_USER_INITIATED_CONNECTION_REQUEST = 0x04000045;
-const UINT32 CLOSE_USER_INITIATED_CONNECTION_RESPONSE = 0x04800045;
-
-const PTHI_MESSAGE_HEADER CLOSE_USER_INITIATED_CONNECTION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{CLOSE_USER_INITIATED_CONNECTION_REQUEST}}, 0
-};
-
-const UINT32 GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST = 0x04000046;
-const UINT32 GET_REMOTE_ACCESS_CONNECTION_STATUS_RESPONSE = 0x04800046;
-
-const PTHI_MESSAGE_HEADER GET_REMOTE_ACCESS_CONNECTION_STATUS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_REMOTE_ACCESS_CONNECTION_STATUS_REQUEST}}, 0
-};
-
-const UINT32 GET_AMT_STATE_REQUEST = 0x01000001;
-const UINT32 GET_AMT_STATE_RESPONSE = 0x01800001;
-
-const PTHI_MESSAGE_HEADER GET_AMT_STATE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_AMT_STATE_REQUEST}}, sizeof(AMT_UUID)
-};
-
-const UINT32 GENERATE_RNG_SEED_REQUEST = 0x04000028;
-const UINT32 GENERATE_RNG_SEED_RESPONSE = 0x04800028;
-
-const PTHI_MESSAGE_HEADER GENERATE_RNG_SEED_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GENERATE_RNG_SEED_REQUEST}}, 0
-};
-
-const UINT32 GET_RNG_SEED_STATUS_REQUEST = 0x0400002E;
-const UINT32 GET_RNG_SEED_STATUS_RESPONSE = 0x0480002E;
-
-const PTHI_MESSAGE_HEADER GET_RNG_SEED_STATUS_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_RNG_SEED_STATUS_REQUEST}}, 0
-};
-
-const UINT32 GET_ZERO_TOUCH_ENABLED_REQUEST = 0x04000030;
-const UINT32 GET_ZERO_TOUCH_ENABLED_RESPONSE = 0x04800030;
-
-const PTHI_MESSAGE_HEADER GET_ZERO_TOUCH_ENABLED_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_ZERO_TOUCH_ENABLED_REQUEST}}, 0
-};
-
-const UINT32 GET_PROVISIONING_TLS_MODE_REQUEST = 0x0400002B;
-const UINT32 GET_PROVISIONING_TLS_MODE_RESPONSE = 0x0480002B;
-
-const PTHI_MESSAGE_HEADER GET_PROVISIONING_TLS_MODE_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_PROVISIONING_TLS_MODE_REQUEST}}, 0
-};
-
-const UINT32 START_CONFIGURATION_REQUEST = 0x04000029;
-const UINT32 START_CONFIGURATION_RESPONSE = 0x04800029;
-
-const PTHI_MESSAGE_HEADER START_CONFIGURATION_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{START_CONFIGURATION_REQUEST}}, 0
-};
-
-const UINT32 SET_PROVISIONING_SERVER_OTP_REQUEST = 0x0400002A;
-const UINT32 SET_PROVISIONING_SERVER_OTP_RESPONSE = 0x0480002A;
-
-const UINT32 SET_DNS_SUFFIX_REQUEST = 0x0400002F;
-const UINT32 SET_DNS_SUFFIX_RESPONSE = 0x0480002F;
-
-const UINT32 ENUMERATE_HASH_HANDLES_REQUEST = 0x0400002C;
-const UINT32 ENUMERATE_HASH_HANDLES_RESPONSE = 0x0480002C;
-
-const PTHI_MESSAGE_HEADER ENUMERATE_HASH_HANDLES_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{ENUMERATE_HASH_HANDLES_REQUEST}}, 0
-};
-
-const UINT32 GET_CERTHASH_ENTRY_REQUEST = 0x0400002D;
-const UINT32 GET_CERTHASH_ENTRY_RESPONSE = 0x0480002D;
-
-const PTHI_MESSAGE_HEADER GET_CERTHASH_ENTRY_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_CERTHASH_ENTRY_REQUEST}}, sizeof(UINT32)
-};
-
-const UINT32 GET_PKI_FQDN_SUFFIX_REQUEST = 0x04000036;
-const UINT32 GET_PKI_FQDN_SUFFIX_RESPONSE = 0x04800036;
-
-const PTHI_MESSAGE_HEADER GET_PKI_FQDN_SUFFIX_HEADER = {
- {AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_PKI_FQDN_SUFFIX_REQUEST}}, 0
-};
-
-#endif
-
diff --git a/usr/src/cmd/lms/heci/StatusCodeDefinitions.h b/usr/src/cmd/lms/heci/StatusCodeDefinitions.h
deleted file mode 100644
index 84e49ee22f..0000000000
--- a/usr/src/cmd/lms/heci/StatusCodeDefinitions.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-//----------------------------------------------------------------------------
-//
-// File: StatusCodeDefinitions.h
-//
-// Notes: This file contains the definitions of the status codes
-// as defined in the Intel® AMT Network Design Guide.
-//
-//----------------------------------------------------------------------------
-
-#ifndef STATUS_CODE_DEFINITIONS_H
-#define STATUS_CODE_DEFINITIONS_H
-
-typedef unsigned int PT_STATUS;
-typedef unsigned int AMT_STATUS;
-
-//Request succeeded
-#define PT_STATUS_SUCCESS 0x0
-#define AMT_STATUS_SUCCESS 0x0
-
-//An internal error in the Intel® AMT device has occurred
-#define PT_STATUS_INTERNAL_ERROR 0x1
-#define AMT_STATUS_INTERNAL_ERROR 0x1
-
-//Intel® AMT device has not progressed far enough in its
-//initialization to process the command.
-#define PT_STATUS_NOT_READY 0x2
-#define AMT_STATUS_NOT_READY 0x2
-
-//Command is not permitted in current operating mode.
-#define PT_STATUS_INVALID_PT_MODE 0x3
-#define AMT_STATUS_INVALID_AMT_MODE 0x3
-
-//Length field of header is invalid.
-#define PT_STATUS_INVALID_MESSAGE_LENGTH 0x4
-#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
-
-//The requested hardware asset inventory table
-//checksum is not available.
-#define PT_STATUS_TABLE_FINGERPRINT_NOT_AVAILABLE 0x5
-#define AMT_STATUS_TABLE_FINGERPRINT_NOT_AVAILABLE 0x5
-
-//The Integrity Check Value field of the request
-//message sent by Intel® AMT enabled device is invalid.
-#define PT_STATUS_INTEGRITY_CHECK_FAILED 0x6
-#define AMT_STATUS_INTEGRITY_CHECK_FAILED 0x6
-
-//The specified ISV version is not supported
-#define PT_STATUS_UNSUPPORTED_ISVS_VERSION 0x7
-#define AMT_STATUS_UNSUPPORTED_ISVS_VERSION 0x7
-
-//The specified queried application is not registered.
-#define PT_STATUS_APPLICATION_NOT_REGISTERED 0x8
-#define AMT_STATUS_APPLICATION_NOT_REGISTERED 0x8
-
-//Either an invalid name or a not previously registered
-//'Enterprise' name was specified
-#define PT_STATUS_INVALID_REGISTRATION_DATA 0x9
-#define AMT_STATUS_INVALID_REGISTRATION_DATA 0x9
-
-//The application handle provided in the request
-//message has never been allocated.
-#define PT_STATUS_APPLICATION_DOES_NOT_EXIST 0xA
-#define AMT_STATUS_APPLICATION_DOES_NOT_EXIST 0xA
-
-//The requested number of bytes cannot be allocated in ISV storage.
-#define PT_STATUS_NOT_ENOUGH_STORAGE 0xB
-#define AMT_STATUS_NOT_ENOUGH_STORAGE 0xB
-
-//The specified name is invalid.
-#define PT_STATUS_INVALID_NAME 0xC
-#define AMT_STATUS_INVALID_NAME 0xC
-
-//The specified block does not exist.
-#define PT_STATUS_BLOCK_DOES_NOT_EXIST 0xD
-#define AMT_STATUS_BLOCK_DOES_NOT_EXIST 0xD
-
-//The specified byte offset is invalid.
-#define PT_STATUS_INVALID_BYTE_OFFSET 0xE
-#define AMT_STATUS_INVALID_BYTE_OFFSET 0xE
-
-//The specified byte count is invalid.
-#define PT_STATUS_INVALID_BYTE_COUNT 0xF
-#define AMT_STATUS_INVALID_BYTE_COUNT 0xF
-
-//The requesting application is not
-//permitted to request execution of the specified operation.
-#define PT_STATUS_NOT_PERMITTED 0x10
-#define AMT_STATUS_NOT_PERMITTED 0x10
-
-//The requesting application is not the owner of the block
-//as required for the requested operation.
-#define PT_STATUS_NOT_OWNER 0x11
-#define AMT_STATUS_NOT_OWNER 0x11
-
-//The specified block is locked by another application.
-#define PT_STATUS_BLOCK_LOCKED_BY_OTHER 0x12
-#define AMT_STATUS_BLOCK_LOCKED_BY_OTHER 0x12
-
-//The specified block is not locked.
-#define PT_STATUS_BLOCK_NOT_LOCKED 0x13
-#define AMT_STATUS_BLOCK_NOT_LOCKED 0x13
-
-//The specified group permission bits are invalid.
-#define PT_STATUS_INVALID_GROUP_PERMISSIONS 0x14
-#define AMT_STATUS_INVALID_GROUP_PERMISSIONS 0x14
-
-//The specified group does not exist.
-#define PT_STATUS_GROUP_DOES_NOT_EXIST 0x15
-#define AMT_STATUS_GROUP_DOES_NOT_EXIST 0x15
-
-//The specified member count is invalid.
-#define PT_STATUS_INVALID_MEMBER_COUNT 0x16
-#define AMT_STATUS_INVALID_MEMBER_COUNT 0x16
-
-//The request cannot be satisfied because a maximum
-//limit associated with the request has been reached.
-#define PT_STATUS_MAX_LIMIT_REACHED 0x17
-#define AMT_STATUS_MAX_LIMIT_REACHED 0x17
-
-//specified key algorithm is invalid.
-#define PT_STATUS_INVALID_AUTH_TYPE 0x18
-#define AMT_STATUS_INVALID_AUTH_TYPE 0x18
-
-//Not Used
-#define PT_STATUS_AUTHENTICATION_FAILED 0x19
-#define AMT_STATUS_AUTHENTICATION_FAILED 0x19
-
-//The specified DHCP mode is invalid.
-#define PT_STATUS_INVALID_DHCP_MODE 0x1A
-#define AMT_STATUS_INVALID_DHCP_MODE 0x1A
-
-//The specified IP address is not a valid IP unicast address.
-#define PT_STATUS_INVALID_IP_ADDRESS 0x1B
-#define AMT_STATUS_INVALID_IP_ADDRESS 0x1B
-
-//The specified domain name is not a valid domain name.
-#define PT_STATUS_INVALID_DOMAIN_NAME 0x1C
-#define AMT_STATUS_INVALID_DOMAIN_NAME 0x1C
-
-//Not Used
-#define PT_STATUS_UNSUPPORTED_VERSION 0x1D
-#define AMT_STATUS_UNSUPPORTED_VERSION 0x1D
-
-//The requested operation cannot be performed because a
-//prerequisite request message has not been received.
-#define PT_STATUS_REQUEST_UNEXPECTED 0x1E
-#define AMT_STATUS_REQUEST_UNEXPECTED 0x1E
-
-//Not Used
-#define PT_STATUS_INVALID_TABLE_TYPE 0x1F
-#define AMT_STATUS_INVALID_TABLE_TYPE 0x1F
-
-//The specified provisioning mode code is undefined.
-#define PT_STATUS_INVALID_PROVISIONING_STATE 0x20
-#define AMT_STATUS_INVALID_PROVISIONING_STATE 0x20
-
-//Not Used
-#define PT_STATUS_UNSUPPORTED_OBJECT 0x21
-#define AMT_STATUS_UNSUPPORTED_OBJECT 0x21
-
-//The specified time was not accepted by the Intel® AMT device
-//since it is earlier than the baseline time set for the device.
-#define PT_STATUS_INVALID_TIME 0x22
-#define AMT_STATUS_INVALID_TIME 0x22
-
-//StartingIndex is invalid.
-#define PT_STATUS_INVALID_INDEX 0x23
-#define AMT_STATUS_INVALID_INDEX 0x23
-
-//A parameter is invalid.
-#define PT_STATUS_INVALID_PARAMETER 0x24
-#define AMT_STATUS_INVALID_PARAMETER 0x24
-
-//An invalid netmask was supplied
-//(a valid netmask is an IP address in which all '1's are before
-//the '0' - e.g. FFFC0000h is valid, FF0C0000h is invalid).
-#define PT_STATUS_INVALID_NETMASK 0x25
-#define AMT_STATUS_INVALID_NETMASK 0x25
-
-//The operation failed because the Flash wear-out
-//protection mechanism prevented a write to an NVRAM sector.
-#define PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED 0x26
-#define AMT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED 0x26
-
-//ME FW did not receive the entire image file.
-#define PT_STATUS_INVALID_IMAGE_LENGTH 0x27
-#define AMT_STATUS_INVALID_IMAGE_LENGTH 0x27
-
-//ME FW received an image file with an invalid signature.
-#define PT_STATUS_INVALID_IMAGE_SIGNATURE 0x28
-#define AMT_STATUS_INVALID_IMAGE_SIGNATURE 0x28
-
-//LME can not support the requested version.
-#define PT_STATUS_PROPOSE_ANOTHER_VERSION 0x29
-#define AMT_STATUS_PROPOSE_ANOTHER_VERSION 0x29
-
-//The PID must be a 64 bit quantity made up of ASCII codes
-//of some combination of 8 characters -
-//capital alphabets (A-Z), and numbers (0-9).
-#define PT_STATUS_INVALID_PID_FORMAT 0x2A
-#define AMT_STATUS_INVALID_PID_FORMAT 0x2A
-
-//The PID must be a 256 bit quantity made up of ASCII codes
-//of some combination of 8 characters -
-//capital alphabets (A-Z), and numbers (0-9).
-#define PT_STATUS_INVALID_PPS_FORMAT 0x2B
-#define AMT_STATUS_INVALID_PPS_FORMAT 0x2B
-
-//Full BIST test has been blocked
-#define PT_STATUS_BIST_COMMAND_BLOCKED 0x2C
-#define AMT_STATUS_BIST_COMMAND_BLOCKED 0x2C
-
-//A TCP/IP connection could not be opened on with the selected port.
-#define PT_STATUS_CONNECTION_FAILED 0x2D
-#define AMT_STATUS_CONNECTION_FAILED 0x2D
-
-//Max number of connection reached.
-//LME can not open the requested connection.
-#define PT_STATUS_CONNECTION_TOO_MANY 0x2E
-#define AMT_STATUS_CONNECTION_TOO_MANY 0x2E
-
-// A process rng generation started.
-#define PT_STATUS_RNG_GENERATION_IN_PROGRESS 0x002F
-#define AMT_STATUS_RNG_GENERATION_IN_PROGRESS 0x002F
-
-//rng doesn't exist
-#define PT_STATUS_RNG_NOT_READY 0x0030
-#define AMT_STATUS_RNG_NOT_READY 0x0030
-
-//Certificate doesn't exist
-#define PT_STATUS_CERTIFICATE_NOT_READY 0x0031
-#define AMT_STATUS_CERTIFICATE_NOT_READY 0x0031
-
-//AMT doesn't grant remote access
-//(AMT has a direct connection to enterprise network).
-#define PT_STATUS_REMOTE_ACCESS_NOT_GRANTED 0x0200
-#define AMT_STATUS_REMOTE_ACCESS_NOT_GRANTED 0x0200
-
-//VPN is disabled (via the AMT Network Interface)
-#define PT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED 0x0201
-#define AMT_STATUS_REMOTE_ACCESS_HOST_VPN_IS_DISABLED 0x0201
-
-//This code establishes a dividing line between
-//status codes which are common to host interface and
-//network interface and status codes which are used by
-//network interface only.
-#define PT_STATUS_NETWORK_IF_ERROR_BASE 0x800
-#define AMT_STATUS_NETWORK_IF_ERROR_BASE 0x800
-
-//The OEM number specified in the remote control
-//command is not supported by the Intel® AMT device
-#define PT_STATUS_UNSUPPORTED_OEM_NUMBER 0x801
-#define AMT_STATUS_UNSUPPORTED_OEM_NUMBER 0x801
-
-//The boot option specified in the remote control command
-//is not supported by the Intel® AMT device
-#define PT_STATUS_UNSUPPORTED_BOOT_OPTION 0x802
-#define AMT_STATUS_UNSUPPORTED_BOOT_OPTION 0x802
-
-//The command specified in the remote control command
-//is not supported by the Intel® AMT device
-#define PT_STATUS_INVALID_COMMAND 0x803
-#define AMT_STATUS_INVALID_COMMAND 0x803
-
-//The special command specified in the remote control command
-//is not supported by the Intel® AMT device
-#define PT_STATUS_INVALID_SPECIAL_COMMAND 0x804
-#define AMT_STATUS_INVALID_SPECIAL_COMMAND 0x804
-
-//The handle specified in the command is invalid
-#define PT_STATUS_INVALID_HANDLE 0x805
-#define AMT_STATUS_INVALID_HANDLE 0x805
-
-//The password specified in the User ACL is invalid
-#define PT_STATUS_INVALID_PASSWORD 0x806
-#define AMT_STATUS_INVALID_PASSWORD 0x806
-
-//The realm specified in the User ACL is invalid
-#define PT_STATUS_INVALID_REALM 0x807
-#define AMT_STATUS_INVALID_REALM 0x807
-
-//The FPACL or EACL entry is used by an active
-//registration and cannot be removed or modified.
-#define PT_STATUS_STORAGE_ACL_ENTRY_IN_USE 0x808
-#define AMT_STATUS_STORAGE_ACL_ENTRY_IN_USE 0x808
-
-//Essential data is missing on CommitChanges command.
-#define PT_STATUS_DATA_MISSING 0x809
-#define AMT_STATUS_DATA_MISSING 0x809
-
-//The parameter specified is a duplicate of an existing value.
-//Returned for a case where duplicate entries are added to FPACL
-//(Factory Partner Allocation Control List) or EACL
-//(Enterprise Access Control List) lists.
-#define PT_STATUS_DUPLICATE 0x80A
-#define AMT_STATUS_DUPLICATE 0x80A
-
-//Event Log operation failed due to the current freeze status of the log.
-#define PT_STATUS_EVENTLOG_FROZEN 0x80B
-#define AMT_STATUS_EVENTLOG_FROZEN 0x80B
-
-//The device is missing private key material.
-#define PT_STATUS_PKI_MISSING_KEYS 0x80C
-#define AMT_STATUS_PKI_MISSING_KEYS 0x80C
-
-//The device is currently generating a keypair.
-//Caller may try repeating this operation at a later time.
-#define PT_STATUS_PKI_GENERATING_KEYS 0x80D
-#define AMT_STATUS_PKI_GENERATING_KEYS 0x80D
-
-//An invalid Key was entered.
-#define PT_STATUS_INVALID_KEY 0x80E
-#define AMT_STATUS_INVALID_KEY 0x80E
-
-//An invalid X.509 certificate was entered.
-#define PT_STATUS_INVALID_CERT 0x80F
-#define AMT_STATUS_INVALID_CERT 0x80F
-
-//Certificate Chain and Private Key do not match.
-#define PT_STATUS_CERT_KEY_NOT_MATCH 0x810
-#define AMT_STATUS_CERT_KEY_NOT_MATCH 0x810
-
-//The request cannot be satisfied because the maximum
-//number of allowed Kerberos domains has been reached.
-//(The domain is determined by the first 24 Bytes of the SID.)
-#define PT_STATUS_MAX_KERB_DOMAIN_REACHED 0x811
-#define AMT_STATUS_MAX_KERB_DOMAIN_REACHED 0x811
-
-// The requested configuration is unsupported
-#define PT_STATUS_UNSUPPORTED 0x812
-#define AMT_STATUS_UNSUPPORTED 0x812
-
-// A profile with the requested priority already exists
-#define PT_STATUS_INVALID_PRIORITY 0x813
-#define AMT_STATUS_INVALID_PRIORITY 0x813
-
-// Unable to find specified element
-#define PT_STATUS_NOT_FOUND 0x814
-#define AMT_STATUS_NOT_FOUND 0x814
-
-// Invalid User credentials
-#define PT_STATUS_INVALID_CREDENTIALS 0x815
-#define AMT_STATUS_INVALID_CREDENTIALS 0x815
-
-// Passphrase is invalid
-#define PT_STATUS_INVALID_PASSPHRASE 0x816
-#define AMT_STATUS_INVALID_PASSPHRASE 0x816
-
-//The application has identified an internal error
-#define PTSDK_STATUS_INTERNAL_ERROR 0x1000
-
-//An ISV operation was called while the library is not
-//initialized
-#define PTSDK_STATUS_NOT_INITIALIZED 0x1001
-
-//The requested library I/F is not supported by the current library
-//implementation.
-#define PTSDK_STATUS_LIB_VERSION_UNSUPPORTED 0x1002
-
-//One of the parameters is invalid (usually indicates a
-//NULL pointer or an invalid session handle is specified)
-#define PTSDK_STATUS_INVALID_PARAM 0x1003
-
-//The SDK could not allocate sufficient resources to complete the operation.
-#define PTSDK_STATUS_RESOURCES 0x1004
-
-//The Library has identified a HW Internal error.
-#define PTSDK_STATUS_HARDWARE_ACCESS_ERROR 0x1005
-
-//The application that sent the request message is not registered.
-//Usually indicates the registration timeout has elapsed.
-//The caller should reregister with the Intel AMT enabled device.
-#define PTSDK_STATUS_REQUESTOR_NOT_REGISTERED 0x1006
-
-//A network error has occurred while processing the call.
-#define PTSDK_STATUS_NETWORK_ERROR 0x1007
-
-//Specified container can not hold the requested string
-#define PTSDK_STATUS_PARAM_BUFFER_TOO_SHORT 0x1008
-
-//For Windows only.
-//ISVS_InitializeCOMinThread was not called by the current thread.
-#define PTSDK_STATUS_COM_NOT_INITIALIZED_IN_THREAD 0x1009
-
-//The URL parameter was not optional in current configuration.
-#define PTSDK_STATUS_URL_REQUIRED 0x100A
-
-//Empty response from PTHI interface
-#define PTHI_STATUS_EMPTY_RESPONSE 0x4000
-
-#endif
diff --git a/usr/src/cmd/lms/heci/heci.h b/usr/src/cmd/lms/heci/heci.h
deleted file mode 100644
index d346a9f627..0000000000
--- a/usr/src/cmd/lms/heci/heci.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __HECI_H__
-#define __HECI_H__
-
-#include <cstring>
-
-#ifdef __sun
-#include <string.h>
-#endif // __sun
-
-#ifndef GUID_DEFINED
-#define GUID_DEFINED
-
-typedef struct guid {
- unsigned int data1;
- unsigned short data2;
- unsigned short data3;
- unsigned char data4[8];
-} GUID;
-
-#endif
-
-#include "HECI_if.h"
-
-class HECI
-{
-public:
- HECI(const GUID guid, bool verbose = true) :
- _initialized(false),
- _verbose(verbose),
- _bufSize(0),
- _protocolVersion(0)
- {
- memcpy(&_guid, &guid, sizeof(_guid));
- }
- virtual ~HECI() {}
-
- virtual bool Init(unsigned char maxProtocolVersion = 0) = 0;
- virtual void Deinit() = 0;
- virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
- virtual int SendMessage(const unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
- virtual unsigned int GetBufferSize() const = 0;
- virtual unsigned char GetProtocolVersion() const = 0;
- virtual bool GetHeciVersion(HECI_VERSION &version) const = 0;
- virtual bool IsInitialized() const = 0;
-
-protected:
- GUID _guid;
- bool _initialized;
- bool _verbose;
- unsigned int _bufSize;
- unsigned char _protocolVersion;
-};
-
-#endif
diff --git a/usr/src/cmd/lms/iatshareddata.h b/usr/src/cmd/lms/iatshareddata.h
deleted file mode 100644
index 0c3c8e73a8..0000000000
--- a/usr/src/cmd/lms/iatshareddata.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef __sun
-#define IATSTATERUNDIR "/var/run/"
-#else
-#define IATSHAREDDATADIR "@prefix@/share"
-#define IATSTATERUNDIR "@IATSTATERUNDIR@"
-#endif
-
diff --git a/usr/src/cmd/lms/lms.xml b/usr/src/cmd/lms/lms.xml
deleted file mode 100644
index 1953589c24..0000000000
--- a/usr/src/cmd/lms/lms.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
-<!--
- Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
-
- The contents of this file are subject to the terms of the
- Common Development and Distribution License (the "License").
- You may not use this file except in compliance with the License.
-
- You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- or http://www.opensolaris.org/os/licensing.
- See the License for the specific language governing permissions
- and limitations under the License.
-
- When distributing Covered Code, include this CDDL HEADER in each
- file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- If applicable, add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your own identifying
- information: Portions Copyright [yyyy] [name of copyright owner]
-
- CDDL HEADER END
-
- NOTE: This service manifest is not editable; its contents will
- be overwritten by package or patch operations, including
- operating system upgrade. Make customizations in a different
- file.
--->
-
-<service_bundle type='manifest' name='SUNWxxxx:lms'>
-
-<service
- name='network/lms'
- type='service'
- version='1'>
-
- <create_default_instance enabled='false' />
-
- <single_instance/>
-
- <!--
- Wait for network interfaces to be initialized.
- -->
- <dependency name='network'
- grouping='require_all'
- restart_on='error'
- type='service'>
- <service_fmri value='svc:/milestone/network:default'/>
- </dependency>
-
- <!--
- Wait for all local filesystems to be mounted.
- -->
- <dependency name='filesystem-local'
- grouping='require_all'
- restart_on='none'
- type='service'>
- <service_fmri
- value='svc:/system/filesystem/local:default'/>
- </dependency>
-
- <exec_method
- type='method'
- name='start'
- exec='/lib/svc/method/svc-lms'
- timeout_seconds='60' >
- <method_context>
- <method_credential
- user='root'
- group='root'
- limit_privileges=':default'
- privileges='basic,net_privaddr'
- />
- </method_context>
- </exec_method>
-
- <exec_method
- type='method'
- name='stop'
- exec=':kill'
- timeout_seconds='60' />
-
- <stability value='External' />
-
- <template>
- <common_name>
- <loctext xml:lang='C'>
- Local Manageability Service
- </loctext>
- </common_name>
- <documentation>
- <manpage title='lms' section='1M'
- manpath='/usr/share/man' />
- </documentation>
- </template>
-</service>
-
-</service_bundle>
diff --git a/usr/src/cmd/lms/main.cpp b/usr/src/cmd/lms/main.cpp
deleted file mode 100644
index 74ae8b128c..0000000000
--- a/usr/src/cmd/lms/main.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "iatshareddata.h"
-#include <cstdlib>
-#include <cstdio>
-#include <cerrno>
-#include <csignal>
-#include <syslog.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include "types.h"
-#include "Protocol.h"
-#include "version.h"
-#include "ATVersion.h"
-#include "glue.h"
-
-#ifdef __sun
-#include <signal.h>
-#endif
-
-#ifdef DAEMON
-#include "daemonize.h"
-#endif //DAEMON
-
-#define LOCK_PATH IATSTATERUNDIR
-/* Change this to whatever your daemon is called */
-#define DAEMON_PID_FILE "lms.pid"
-
-#define QUICK_CONNECT_COUNT 30
-#define SLEEP_TIMEOUT 30
-#define QUICK_SLEEP_TIMEOUT 5
-
-
-bool isRunning(int running = -1)
-{
- static int _running = 0;
- if (running >= 0)
- {
- _running = running;
- }
- if (_running == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-void log(void *param, LPCTSTR message, WORD eventType)
-{
-#ifdef DEBUGLOG
- syslog((int)eventType, "%s", message);
-#endif
-}
-
-//This needs to be global for termination action
-Protocol prot;
-int lock_pid_file_fd = -1;
-glue plugin;
-
-void exitcleanup()
-{
- prot.Deinit();
- prot.DestroySockets();
- //syslog(EVENTLOG_INFORMATION_TYPE, "Service stopped\n");
- closelog();
- if (-1 != lock_pid_file_fd) {
- close(lock_pid_file_fd);
- lock_pid_file_fd = -1;
- unlink(LOCK_PATH DAEMON_PID_FILE);
- }
-
- plugin.deinit();
-}
-
-//Action termination
-#ifdef __sun
-extern "C"
-#endif
-void terminationHandler(int signum, siginfo_t *sinfo, void *dummy)
-{
- PRINT("LMS Service received - Signal:%d Err:(%d) Code:(%d)\n", signum, sinfo->si_errno, sinfo->si_code);
- if (isRunning()) {
- syslog(EVENTLOG_WARNING_TYPE, "Received termination signal (%d)\n", signum);
-
- isRunning(0);
-
- exit(EXIT_SUCCESS);
- }
-}
-
-void setTerminationHandler()
-{
- int sigSet = 0;
- // Termination signal handler.
- struct sigaction terminateAction;
- // Set up the structure to specify the termination action.
- terminateAction.sa_sigaction = terminationHandler;
- sigemptyset(&terminateAction.sa_mask);
- terminateAction.sa_flags = SA_SIGINFO;
- sigSet &= sigaction(SIGTERM, &terminateAction, NULL);
- sigSet &= sigaction(SIGQUIT, &terminateAction, NULL);
- sigSet &= sigaction(SIGINT, &terminateAction, NULL);
- sigSet &= sigaction(SIGHUP, &terminateAction, NULL);
- sigSet &= sigaction(SIGPIPE, &terminateAction, NULL);
- sigSet &= sigaction(SIGALRM, &terminateAction, NULL);
- sigSet &= sigaction(SIGUSR1, &terminateAction, NULL);
- sigSet &= sigaction(SIGUSR2, &terminateAction, NULL);
-
- if (sigSet != 0) {
- syslog(EVENTLOG_WARNING_TYPE, "Failed to register terminate signal handler\n");
- }
-}
-
-/*
- * return: 1 if the lock is real, 0 if not real, -1 on error
- **/
-int lock_is_real(const char *lockfile)
-{
- int lfp;
- char pid_buf[32];
- ssize_t count = 0;
- int lockpid;
-
- lfp = open(lockfile, O_RDONLY);
- if (lfp < 0) {
- syslog(LOG_ERR,
- "unable to open lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
-
- count = read(lfp, pid_buf, sizeof(pid_buf)-1);
- if (count < 1) {
- syslog(LOG_ERR,
- "unable to read lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- close(lfp);
- return -1;
- }
- close(lfp);
- pid_buf[count] = '\0';
-
- lockpid = atoi(pid_buf);
- if (lockpid <= 1) {
- syslog(LOG_ERR, "bad pid in lock file %s", lockfile);
- return 0;
- }
-
- /* See if the process still exists */
- if (kill(lockpid, 0) == 0) {
- /* Process exists, lock is real */
- return 1;
- }
- else {
- /* Process is gone */
- return 0;
- }
-}
-
-/**
- * lock_pid_file - creates a pid file and writes current process pid into it
- *
- * lockfile - name of a file to be created
- *
- * return: 0 on success, -1 on fatal error, -2 on error
- **/
-int lock_pid_file(const char *lockfile)
-{
- int lfp = -1;
- size_t towrite = 0;
- ssize_t written = 0;
- int error = 0;
- int haserror = 0;
- char pid_buf[32];
-
- /* Create the lock file as the current user */
- if (lockfile && lockfile[0]) {
-#ifdef __sun
- lfp = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0644);
- if (lfp < 0) {
- if (errno == EEXIST) {
- if (lock_is_real(lockfile)) {
- syslog(LOG_ERR,
- "The LMS service is already running!");
- }
- else {
- unlink(lockfile);
- }
- return -2;
- }
- else {
- syslog(LOG_ERR,
- "unable to lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
- }
- snprintf(pid_buf, sizeof(pid_buf), "%u", getpid());
- towrite = strnlen(pid_buf, 31);
- written = write(lfp, pid_buf, towrite);
-#else
- lfp = open(lockfile, O_RDWR | O_CREAT, 0644);
- if (lfp < 0) {
- syslog(LOG_ERR,
- "unable to create lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- return -1;
- }
-
- if (-1 == flock(lfp, LOCK_EX | LOCK_NB)) {
- error = errno;
- if (EWOULDBLOCK == errno) {
- syslog(LOG_ERR, "The LMS service is already running!");
- close(lfp);
- } else {
- syslog(LOG_ERR,
- "unable to lock file %s, code=%d (%s)",
- lockfile, error, strerror(error));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
- return -1;
- }
- if (-1 == ftruncate(lfp, 0)) {
- syslog(LOG_ERR,
- "unable to fruncate lock file %s, code=%d (%s)",
- lockfile, errno, strerror(errno));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
- snprintf(pid_buf, sizeof(pid_buf), "%u", getpid());
- towrite = strnlen(pid_buf, 31);
- written = write(lfp, pid_buf, towrite);
- if (-1 == written) {
- error = errno;
- haserror = 1;
- } else if (towrite != (size_t)written) {
- haserror = 1;
- } else if (-1 == fsync(lfp)) {
- error = errno;
- haserror = 1;
- }
- if (1 == haserror) {
- syslog(LOG_ERR,
- "unable to write pid into lock file %s, code=%d (%s)",
- lockfile, error, strerror(error));
- close(lfp);
- unlink(lockfile);
- return -2;
- }
-#endif // __sun
- lock_pid_file_fd = lfp;
- }
- return 0;
-}
-
-
-int main(int argc, char **argv)
-{
- bool alreadyFailed = false;
- bool firstLoop = true;
- bool init = false;
- int connectCount = 0;
- int lockresult = -1;
-
- if (ATVersion::ShowVersionIfArg(argc, const_cast<const char **>(argv), VER_PRODUCTVERSION_STR)) {
- return 0;
- }
-
- umask(022);
-
- openlog("LMS", LOG_CONS, LOG_DAEMON);
-
-#ifdef DAEMON
- daemonize();
-#else
- setTerminationHandler();
-#endif
-
- lockresult = lock_pid_file(LOCK_PATH DAEMON_PID_FILE);
- if (-2 == lockresult) {
- lockresult = lock_pid_file(LOCK_PATH DAEMON_PID_FILE);
- }
- if (0 != lockresult) {
- exit(EXIT_FAILURE);
- }
-
- isRunning(1);
- //syslog(EVENTLOG_INFORMATION_TYPE, "Service started\n");
-
- atexit(exitcleanup);
-
- plugin.init();
-
- while (isRunning()) {
- if (!prot.IsInitialized()) {
- if (init) {
-#ifdef DEBUGLOG
- log(NULL, "LMS Service lost connection to AMT via HECI driver", EVENTLOG_ERROR_TYPE);
-#endif
- init = false;
- }
-
- if (!prot.Init(log, NULL)) {
- if (firstLoop) {
- syslog(EVENTLOG_ERROR_TYPE, "Cannot connect to AMT via HECI driver");
- firstLoop = false;
- }
- // Failed to connect to the HECI driver.
- // Sleep for a second and try again.
- connectCount++;
- if (connectCount >= QUICK_CONNECT_COUNT) {
- sleep(SLEEP_TIMEOUT);
- } else {
- sleep(QUICK_SLEEP_TIMEOUT);
- }
- continue;
- }
- init = true;
- firstLoop = false;
- connectCount = 0;
-#ifdef DEBUGLOG
- log(NULL, "Connected to AMT via HECI driver\n", EVENTLOG_INFORMATION_TYPE);
-#endif
- }
-
- if (!prot.SocketsCreated()) {
- if (!prot.CreateSockets()) {
- if (!alreadyFailed) {
-#ifdef DEBUGLOG
- log(NULL, "LMS Service has a problem in achieving network resources.", EVENTLOG_ERROR_TYPE);
-#endif
- alreadyFailed = true;
- }
- continue;
- } else {
- alreadyFailed = false;
- }
- }
- // Select on active sockets (IANA ports and open connections).
- prot.Select();
- }
-
- return 0;
-}
diff --git a/usr/src/cmd/lms/plugin.h b/usr/src/cmd/lms/plugin.h
deleted file mode 100644
index 7ff0b922a5..0000000000
--- a/usr/src/cmd/lms/plugin.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __LMS_PLUGIN_H__
-#define __LMS_PLUGIN_H__
-
-#define LMS_OK 0x0
-#define LMS_ERROR 0x1
-
-#define LMS_ACCEPTED 0x1
-#define LMS_DROPPED 0x2
-#define LMS_STOPPED 0x3
-
-
-#ifdef __sun
-#define LMS_PLUGIN_CONFIG_FILE "/etc/lms_plugin.conf"
-#else
-#define LMS_PLUGIN_CONFIG_FILE "@prefix@/etc/lms_plugin.conf"
-#endif
-
-#define LMS_INIT_FUNC_NAME "lms_init_func"
-#define LMS_VERSION_FUNC_NAME "lms_version_func"
-#define LMS_PRE_FUNC_NAME "lms_pre_func"
-#define LMS_RETRY_FUNC_NAME "lms_retry_func"
-#define LMS_POST_FUNC_NAME "lms_post_func"
-#define LMS_DEINIT_FUNC_NAME "lms_deinit_func"
-
-
-typedef int (*lms_init_t)(void);
-typedef void (*lms_version_t)(unsigned char version);
-typedef int (*lms_pre_t)(unsigned char *buff, int len);
-typedef int (*lms_retry_t)(unsigned char *buff, int len);
-typedef int (*lms_post_t)(unsigned char *buff, int len, int status);
-typedef void (*lms_deinit_t)(void);
-
-
-#endif
-
diff --git a/usr/src/cmd/lms/svc-lms b/usr/src/cmd/lms/svc-lms
deleted file mode 100644
index 509a6bbb1f..0000000000
--- a/usr/src/cmd/lms/svc-lms
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/sbin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-. /lib/svc/share/smf_include.sh
-
-[ ! -x /usr/lib/lms ] && exit $SMF_EXIT_ERR_CONFIG
-
-# Check for an lms process and exit
-# if the daemon is already running.
-
-if /usr/bin/pgrep -x -u 0 -z `smf_zonename` lms >/dev/null 2>&1; then
- echo "$0: lms is already running"
- exit 1
-fi
-
-/usr/lib/lms &
diff --git a/usr/src/cmd/lms/tools/ATNetworkTool.cpp b/usr/src/cmd/lms/tools/ATNetworkTool.cpp
deleted file mode 100644
index 8261a42268..0000000000
--- a/usr/src/cmd/lms/tools/ATNetworkTool.cpp
+++ /dev/null
@@ -1,735 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ATNetworkTool.h"
-#include <sstream>
-#include <algorithm>
-#include <cerrno>
-#include <net/if.h>
-#include <netdb.h>
-
-#ifdef __sun
-#include <arpa/inet.h>
-#include <sys/sockio.h>
-#include <stdio.h>
-#include <stropts.h>
-#else
-#include <ifaddrs.h>
-#endif // __sun
-
-#include <unistd.h>
-#include <fcntl.h>
-
-bool ATNetworkTool::GetHostNameDomain(const char *name, std::string &domain)
-{
- const char *domp = strchr(name, '.');
- if (domp) {
- domp++;
- if (*domp) {
-#ifdef LMS_NET_DEBUG
- printf("D: %s\n", domp);
-#endif
- domain = domp;
- return true;
- }
- }
- return false;
-}
-
-bool ATNetworkTool::GetHentDomain(struct hostent *hent, std::string &domain)
-{
- if (NULL == hent) {
- return false;
- }
- if (NULL == hent->h_name) {
- return false;
- }
-
-#ifdef LMS_NET_DEBUG
- printf("N: %s\n", hent->h_name);
-#endif
- if (ATNetworkTool::GetHostNameDomain(hent->h_name, domain)) {
- return true;
- }
-
- if (NULL != hent->h_aliases) {
- for (char **ssx = hent->h_aliases; ssx && *ssx; ssx++) {
-#ifdef LMS_NET_DEBUG
- printf("A: %s\n", *ssx);
-#endif
- if (ATNetworkTool::GetHostNameDomain(*ssx, domain)) {
- return true;
- }
- }
- }
- return false;
-}
-
-bool ATNetworkTool::GetIPDomain(const ATAddress &ip, std::string &domain, int &error)
-{
- char hbuf[NI_MAXHOST];
-
- if (0 != (error = getnameinfo(ip.addr(), ip.size(),
- hbuf, sizeof(hbuf),
- NULL, 0,
- NI_NAMEREQD))) {
- return false;
- }
-
- return ATNetworkTool::GetHostNameDomain(hbuf, domain);
-}
-
-int ATNetworkTool::GetLocalIPs(ATAddressList &addresses, int &error, int family, bool withloopback)
-{
- struct ifaddrs *ifap;
-
-#ifdef __sun
-
- char buf[1024];
- struct ifconf ifc;
- struct ifreq *ifr;
- int sock;
- int nInterfaces;
- int i;
-
- addresses.clear();
-
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- if(sock < 0)
- {
- perror("socket");
- return 1;
- }
-
- /* Query available interfaces. */
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- if(ioctl(sock, SIOCGIFCONF, &ifc) < 0)
- {
- perror("ioctl(SIOCGIFCONF)");
- close(sock);
- return 1;
- }
-
- /* Iterate through the list of interfaces. */
- ifr = ifc.ifc_req;
- nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
- for(i = 0; i < nInterfaces; i++)
- {
- struct ifreq *item = &ifr[i];
-
- if (item->ifr_flags & IFF_LOOPBACK)
- continue;
-
- addresses.insert(&item->ifr_addr);
- }
-
- close(sock);
-
-#else // ! __sun
-
- if (0 != getifaddrs(&ifap)) {
- error = errno;
- return -1;
- }
-
- addresses.clear();
- for (struct ifaddrs *ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (NULL == ifa->ifa_addr) {
- continue;
- }
- if ((ifa->ifa_flags & IFF_UP) == 0) {
- continue;
- }
- if ((!withloopback) &&
- (((ifa->ifa_flags & IFF_LOOPBACK) != 0) ||
- ((ifa->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT)) == 0))) {
- continue;
- }
-
- if (AF_UNSPEC != family) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(ifa->ifa_addr)) {
- continue;
- }
- } else {
- if (ifa->ifa_addr->sa_family != family) {
- continue;
- }
- }
- }
-
- addresses.insert(ifa->ifa_addr);
- }
- freeifaddrs(ifap);
-
-#endif // __sun
-
- return 0;
-}
-
-int ATNetworkTool::GetLocalNetDomains(ATDomainMap &domains, int &error, int family)
-{
- int ret;
- ATAddressList addresses;
-
- if (0 != (ret = ATNetworkTool::GetLocalIPs(addresses, error, family))) {
- return ret;
- }
-
- domains.clear();
- ATAddressList::iterator aend = addresses.end();
- for (ATAddressList::iterator ait = addresses.begin();
- ait != aend;
- ait++)
- {
- std::string domain;
- if (ATNetworkTool::GetIPDomain(*ait, domain, error)) {
- domains[*ait] = domain;
- }
- }
- return 0;
-}
-
-int ATNetworkTool::GetSockDomain(int sock, std::string &domain, int &error)
-{
- struct sockaddr_storage ss;
- socklen_t salen = sizeof(ss);
- struct sockaddr *sa;
-
- sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &salen) != 0) {
- error = errno;
- return -1;
- }
-
- if (ATNetworkTool::GetIPDomain(sa, domain, error)) {
- return 1;
- }
- return 0;
-}
-
-int ATNetworkTool::GetSockPeerIPs(int sock, ATAddressList &addresses, int &error,
- int family, bool zeroport)
-{
- struct sockaddr_storage ss;
- socklen_t salen = sizeof(ss);
- struct sockaddr *sa;
- struct addrinfo hints, *paddr, *paddrp;
-
- sa = (struct sockaddr *)&ss;
-
- if (getpeername(sock, sa, &salen) != 0) {
- error = errno;
- return -1;
- }
-
- char hbuf[NI_MAXHOST];
- char pbuf[NI_MAXSERV];
- if (0 != (error = getnameinfo(sa, salen,
- hbuf, sizeof(hbuf),
- pbuf, sizeof(pbuf),
- 0))) {
- return -1;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = SOCK_STREAM;
- if (0 != (error = getaddrinfo(hbuf, pbuf, &hints, &paddrp))) {
- return -1;
- }
- addresses.clear();
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
- if (zeroport) {
- addresses.insert(ATAddress(paddr->ai_addr, 0));
- } else {
- addresses.insert(paddr->ai_addr);
- }
- }
- freeaddrinfo(paddrp);
- return 0;
-}
-
-int ATNetworkTool::IsSockPeerLocal(int sock, int &error, int family)
-{
- ATAddressList localAddresses;
- ATAddressList targAddresses;
-
- if (0 != ATNetworkTool::GetSockPeerIPs(sock, targAddresses, error,
- family, true)) {
- return -1;
- }
- if (0 != ATNetworkTool::GetLocalIPs(localAddresses, error,
- family, true)) {
- return -1;
- }
- if (std::includes(localAddresses.begin(), localAddresses.end(),
- targAddresses.begin(), targAddresses.end())) {
- return 1;
- }
- return 0;
-}
-
-int ATNetworkTool::CloseSocket(int s)
-{
- shutdown(s, SHUT_RDWR);
- return close(s);
-}
-
-int ATNetworkTool::CreateSocket(const struct addrinfo *addr, int &error)
-{
- return ATNetworkTool::CreateSocket(addr->ai_addr, addr->ai_addrlen,
- error,
- addr->ai_family, addr->ai_socktype,
- addr->ai_protocol);
-}
-
-int ATNetworkTool::CreateSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error,
- int family, int socktype, int protocol)
-{
- int s = socket(family, socktype, protocol);
- if (s < 0) {
- error = errno;
- return -1;
- }
-
- if (socktype != SOCK_DGRAM) {
- linger l;
- l.l_onoff = 0;
- l.l_linger = 0;
- if (setsockopt(s, SOL_SOCKET, SO_LINGER,
- (char *)&l, sizeof(l)) == -1) {
- error = errno;
- close(s);
- return -1;
- }
- }
-
- if (bind(s, addr, addrlen) == -1) {
- error = errno;
- close(s);
- return -1;
- }
-
- return s;
-}
-
-int ATNetworkTool::ConnectSocket(struct addrinfo *addr,
- int &error, bool loopback)
-{
- return ATNetworkTool::ConnectSocket(addr->ai_addr, addr->ai_addrlen,
- error, loopback,
- addr->ai_family, addr->ai_socktype,
- addr->ai_protocol);
-}
-
-int ATNetworkTool::ConnectSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error, bool loopback,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if (!loopback) {
- hints.ai_flags |= AI_PASSIVE;
- }
- if ((error = getaddrinfo(NULL, "0", &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::CreateSocket(paddr, error);
- if (s < 0) {
- continue;
- }
-
- if (connect(s, addr, addrlen) != 0) {
- error = errno;
- ATNetworkTool::CloseSocket(s);
- continue;
- }
-
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-int ATNetworkTool::CreateServerSocket(in_port_t port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog)
-{
- std::stringstream ssport;
-
- ssport << port;
- return ATNetworkTool::CreateServerSocket(ssport.str().c_str(),
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog);
-}
-
-int ATNetworkTool::CreateServerSocket(const char *port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog)
-{
- ATSocketList sockets;
- int s = -1;
-
- int num = ATNetworkTool::CreateServerSockets(sockets, port,
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog, true);
- if ((num > 0) && (sockets.size() > 0)) {
- s = sockets[0];
- }
- sockets.clear();
- return s;
-}
-
-
-int ATNetworkTool::CreateServerSockets(ATSocketList &sockets, in_port_t port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog, bool one)
-{
- std::stringstream ssport;
-
- ssport << port;
- return ATNetworkTool::CreateServerSockets(sockets, ssport.str().c_str(),
- error,
- loopback, nonblocking,
- family, socktype, protocol,
- backlog, one);
-}
-
-int ATNetworkTool::CreateServerSockets(ATSocketList &sockets, const char *port,
- int &error,
- bool loopback, bool nonblocking,
- int family, int socktype, int protocol,
- int backlog, bool one)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int num = 0;
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if (!loopback) {
- hints.ai_flags |= AI_PASSIVE;
- }
- if ((error = getaddrinfo(NULL, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::CreateServerSocket(paddr, error,
- nonblocking,
- backlog);
- if (s < 0) {
- continue;
- }
- sockets.push_back(s);
- num++;
- if (one) {
- break;
- }
- }
- freeaddrinfo(paddrp);
- return num;
-}
-
-int ATNetworkTool::CreateServerSocket(const struct addrinfo *addr, int &error,
- bool nonblocking, int backlog)
-{
- int s = ATNetworkTool::CreateSocket(addr, error);
- if (s < 0) {
- return -1;
- }
-
- if (nonblocking) {
- ATNetworkTool::SetNonBlocking(s);
- }
-
- if (listen(s, backlog) == -1) {
- error = errno;
- ATNetworkTool::CloseSocket(s);
- return -1;
- }
-
- return s;
-}
-
-int ATNetworkTool::SetNonBlocking(int s, bool block)
-{
- if (block) {
- return fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK);
- } else {
- return fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK);
- }
-}
-
-int ATNetworkTool::ConnectToSocket(int sock, int &error, bool loopback,
- int socktype, int protocol)
-{
- struct sockaddr_storage ss;
- socklen_t addrLen = sizeof(ss);
- struct sockaddr *sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &addrLen) != 0) {
- error = errno;
- return -1;
- }
- int s = ATNetworkTool::ConnectSocket(sa, addrLen,
- error, loopback,
- sa->sa_family,
- socktype, protocol);
- if (s < 0) {
- return -1;
- }
- return s;
-}
-
-int ATNetworkTool::Connect(const char *host, in_port_t port,
- int &error,
- int family, int socktype, int protocol)
-{
- std::stringstream ssport;
-
- ssport << port;
-
- return ATNetworkTool::Connect(host, ssport.str().c_str(), error,
- family, socktype, protocol);
-}
-
-int ATNetworkTool::Connect(const char *host, const char *port,
- int &error,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- if (socktype != SOCK_DGRAM) {
- socktype = SOCK_STREAM;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
- hints.ai_flags = AI_NUMERICHOST;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(host, port, &hints, &paddrp)) != 0) {
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(host, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::ConnectSocket(paddr, error);
- if (s < 0) {
- continue;
- }
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-int ATNetworkTool::ConnectLoopback(in_port_t port,
- int &error,
- int family, int socktype, int protocol)
-{
- std::stringstream ssport;
-
- ssport << port;
-
- return ATNetworkTool::ConnectLoopback(ssport.str().c_str(), error,
- family, socktype, protocol);
-}
-
-int ATNetworkTool::ConnectLoopback(const char *port,
- int &error,
- int family, int socktype, int protocol)
-{
- struct addrinfo hints, *paddr, *paddrp;
- int oks = -1;
-
- if (socktype != SOCK_DGRAM) {
- socktype = SOCK_STREAM;
- }
-
- memset(&hints, 0, sizeof(hints));
- if (ATNetworkTool::AF_XINETX == family) {
- hints.ai_family = PF_UNSPEC;
- } else {
- hints.ai_family = family;
- }
- hints.ai_socktype = socktype;
- hints.ai_protocol = protocol;
-#ifdef AI_NUMERICSERV
- hints.ai_flags |= AI_NUMERICSERV;
-#endif
- if ((error = getaddrinfo(NULL, port, &hints, &paddrp)) != 0) {
- return -1;
- }
- for (paddr = paddrp; paddr; paddr = paddr->ai_next) {
- if (ATNetworkTool::AF_XINETX == family) {
- if (!ATAddress::saIsInet(paddr->ai_addr)) {
- continue;
- }
- }
-
- int s = ATNetworkTool::ConnectSocket(paddr, error, true);
- if (s < 0) {
- continue;
- }
- oks = s;
- break;
- }
- freeaddrinfo(paddrp);
- return oks;
-}
-
-unsigned int ATNetworkTool::GetLocalPort(int sock)
-{
- struct sockaddr_storage ss;
- socklen_t addrLen = sizeof(ss);
- struct sockaddr *sa = (struct sockaddr *)&ss;
-
- if (getsockname(sock, sa, &addrLen) != 0) {
- return 0;
- }
- switch (sa->sa_family) {
- case AF_INET6:
- return ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
- break;
- case AF_INET:
- return ntohs(((struct sockaddr_in *)sa)->sin_port);
- break;
- }
- return 0;
-}
-
-int ATNetworkTool::Accept(int s, ATAddress &address,
- int &error, bool nonblocking)
-{
- struct sockaddr_storage saddr;
- socklen_t addrLen = sizeof(saddr);
- struct sockaddr *addr = (struct sockaddr *)&saddr;
-
- int s_new = accept(s, addr, &addrLen);
- if (s_new == -1) {
- error = errno;
- return -1;
- }
-
- address = addr;
-
- ATNetworkTool::SetNonBlocking(s_new, nonblocking);
-
- return s_new;
-}
-
diff --git a/usr/src/cmd/lms/tools/ATNetworkTool.h b/usr/src/cmd/lms/tools/ATNetworkTool.h
deleted file mode 100644
index 00cda38d08..0000000000
--- a/usr/src/cmd/lms/tools/ATNetworkTool.h
+++ /dev/null
@@ -1,553 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _AT_NETWORK_TOOL_H_
-#define _AT_NETWORK_TOOL_H_
-
-#include <string>
-#include <set>
-#include <vector>
-#include <map>
-#include <cstring>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-class ATAddress
-{
-private:
- struct sockaddr_storage ip;
-
-public:
-
- ATAddress()
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- };
-
- ATAddress(const ATAddress &y)
- {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- };
-
- ATAddress(const struct sockaddr *yip)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), yip, saSize(yip));
- };
-
- ATAddress(const ATAddress &y, in_port_t yport)
- {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- ATAddress::saSetPort((const struct sockaddr *)&(this->ip), yport);
- };
-
- ATAddress(const struct sockaddr *yip, in_port_t yport)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), yip, saSize(yip));
- ATAddress::saSetPort((const struct sockaddr *)&(this->ip), yport);
- };
-
- static void saSetPort(const struct sockaddr *ip, in_port_t yport)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- ((struct sockaddr_in6 *)ip)->sin6_port = htons(yport);
- break;
-
- case AF_INET:
- ((struct sockaddr_in *)ip)->sin_port = htons(yport);
- break;
- }
- }
-
- static bool saIsInet(const struct sockaddr *ip)
- {
- return ((ip->sa_family == AF_INET) || (ip->sa_family == AF_INET6));
- };
-
- static unsigned int saSize(const struct sockaddr *ip)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- return sizeof(struct sockaddr_in6);
- break;
-
- case AF_INET:
- return sizeof(struct sockaddr_in);
- break;
-
- default:
- return 0;
- }
- };
-
- static in_port_t saInPort(const struct sockaddr *ip)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- return ntohs(((struct sockaddr_in6 *)ip)->sin6_port);
- break;
-
- case AF_INET:
- return ntohs(((struct sockaddr_in *)ip)->sin_port);
- break;
-
- default:
- return 0;
- }
- };
-
- static const void *saInAddr(const struct sockaddr *ip, size_t &asize)
- {
- switch (ip->sa_family) {
- case AF_INET6:
- asize = sizeof(in6_addr);
- return (const void *)&(((struct sockaddr_in6 *)ip)->sin6_addr);
- break;
-
- case AF_INET:
- asize = sizeof(in_addr);
- return (const void *)&(((struct sockaddr_in *)ip)->sin_addr);
- break;
-
- default:
- asize = 0;
- return NULL;
- }
- };
-
- static const char *saInNtoP(const struct sockaddr *ip, char *buf, size_t buflen)
- {
- if (!ATAddress::saIsInet(ip)) {
- return NULL;
- }
-
- size_t asize;
- const void *src = ATAddress::saInAddr(ip, asize);
- if (NULL == src) {
- return NULL;
- }
- return inet_ntop(ip->sa_family, src, buf, buflen);
- };
-
- sa_family_t family() const { return ip.ss_family; };
-
- bool isInet() const { return ((ip.ss_family == AF_INET) || (ip.ss_family == AF_INET6)); };
-
- unsigned int size() const
- {
- return ATAddress::saSize((const struct sockaddr *)&(this->ip));
- };
-
- const struct sockaddr *addr() const
- {
- return (const struct sockaddr *)&ip;
- };
-
- in_port_t inPort() const
- {
- return ATAddress::saInPort((const struct sockaddr *)&(this->ip));
- };
-
- const void *inAddr(size_t &asize) const
- {
- return ATAddress::saInAddr((const struct sockaddr *)&(this->ip), asize);
- };
-
- const char *inNtoP(char *buf, size_t buflen)
- {
- return ATAddress::saInNtoP((const struct sockaddr *)&(this->ip), buf, buflen);
- };
-
- ATAddress &operator=(const ATAddress &y)
- {
- if (this != &y) {
- memcpy(&(this->ip), y.addr(), sizeof(struct sockaddr_storage));
- }
- return *this;
- };
-
- ATAddress &operator=(const struct sockaddr &yip)
- {
- memset(&(this->ip), 0, sizeof(struct sockaddr_storage));
- memcpy(&(this->ip), &yip, saSize(&yip));
- return *this;
- };
-
- int compare(const ATAddress &y) const
- {
- if (this->family() != y.family()) {
- return (this->family() - y.family());
- }
-
- size_t asize = 0;
- const void *a = this->inAddr(asize);
- const void *b = y.inAddr(asize);
- if ((0 != asize) && (NULL != a) && (NULL != b)) {
- int adiff = memcmp(a, b, asize);
- if (adiff != 0) {
- return adiff;
- }
- }
-
- in_port_t ap = this->inPort();
- in_port_t bp = y.inPort();
- if ((ap == 0) || (bp == 0)) {
- return 0;
- }
- if (ap != bp) {
- return (ap - bp);
- }
-
- return memcmp(&(this->ip), y.addr(), this->size());
- };
-
- bool operator<(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- return (this->compare(y) < 0);
- };
-
- bool operator>(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- return (this->compare(y) > 0);
- };
-
- bool operator==(const ATAddress &y) const
- {
- if (this == &y) {
- return true;
- }
- if (this->family() != y.family()) {
- return false;
- }
- return (memcmp(&(this->ip), y.addr(), this->size()) == 0);
- };
-
- bool operator!=(const ATAddress &y) const
- {
- if (this == &y) {
- return false;
- }
- if (this->family() != y.family()) {
- return true;
- }
- return (memcmp(&(this->ip), y.addr(), this->size()) != 0);
- };
-
- static bool IsAddressIP(const char *address, int family = AF_INET)
- {
- struct sockaddr_storage inaddr;
-
- if (address == NULL) {
- return false;
- }
- return (0 < inet_pton(family, address, &inaddr));
- };
-};
-
-
-typedef std::set<ATAddress> ATAddressList;
-typedef std::map<ATAddress, std::string> ATDomainMap;
-typedef std::vector<int> ATSocketList;
-
-class ATNetworkTool
-{
-public:
- static const int DefaultBacklog = 5;
- static const int DefaultFamily = AF_INET;
- static const int AF_XINETX = AF_MAX + 10;
-
- /* Gets Domain name from Hostname
- * @param name hostname
- * @param domain [out] domain name
- * @return bool true if success, false if domain unknown
- */
- static bool GetHostNameDomain(const char *name, std::string &domain);
-
- /* Gets Domain name from IP
- * @param ip address
- * @param domain [out] domain name
- * @param error [out] error code
- * @return bool true if success, false if domain unknown
- */
- static bool GetIPDomain(const ATAddress &ip, std::string &domain, int &error);
-
- /* Gets Domain name from host entry
- * @param hent pointer to host entry structure
- * @param domain [out] domain name
- * @return bool true if success, false if domain unknown
- */
- static bool GetHentDomain(struct hostent *hent, std::string &domain);
-
- /* Gets Domain name from socket
- * @param sock checked socket
- * @param domain [out] domain name
- * @param error [out] error code
- * @return int ==1 if success, <0 on error, ==0 if no domain
- */
- static int GetSockDomain(int sock, std::string &domain, int &error);
-
- /* Gets all local (IPv4/6) from local running network interfaces
- * @param addresses [out] set of local IP addresses
- * @param error [out] error code
- * @param family filtered address family
- * @param withloopback true if get loopback addresses too
- * @return int ==0 if success, !=0 on error
- */
- static int GetLocalIPs(ATAddressList &addresses, int &error,
- int family = ATNetworkTool::AF_XINETX,
- bool withloopback = false);
-
- /* Gets all local domains from local running network interfaces
- * @param domains [out] map of <local IP address> => <domain name>
- * @param error [out] error code
- * @param family filtered address family
- * @return int ==0 if success, !=0 on error
- */
- static int GetLocalNetDomains(ATDomainMap &domains, int &error,
- int family = ATNetworkTool::AF_XINETX);
-
- /* Gets all (IPv4/6) network interfaces of socket peer
- * @param addresses [out] set of peer IP addresses
- * @param error [out] error code
- * @param family filtered address family
- * @param zeroport set port to 0 in result list
- * @return int ==0 if success, !=0 on error
- */
- static int GetSockPeerIPs(int sock, ATAddressList &addresses,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- bool zeroport = false);
-
- /* Checks if socket peer is (IPv4/6) local address
- * @param sock checked socket
- * @param error [out] error code
- * @param family filtered address family
- * @return int ==1 if peer is local, ==0 if remote, <0 on error
- */
- static int IsSockPeerLocal(int sock, int &error,
- int family = ATNetworkTool::AF_XINETX);
-
- /* Closes socket
- * @param s socket to close
- * @return int ==0 if success, !=0 on error
- */
- static int CloseSocket(int s);
-
- /* Sets/removes O_NONBLOCKING flag to socket
- * @param s socket
- * @param block - true to set flag, false to remove flag
- * @return int ==0 if success, !=0 on error
- */
- static int SetNonBlocking(int s, bool block = true);
-
- /* Creates socket
- * @param addr socket parameters
- * @param error [out] error code
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateSocket(const struct addrinfo *addr, int &error);
-
- /* Creates socket
- * @param addr socket address
- * @param addrlen socket address length
- * @param error [out] error code
- * @param family socket expected family
- * @param socktype socket type
- * @param protocol socket protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error,
- int family = ATNetworkTool::DefaultFamily,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Creates server listening socket
- * @param addr socket parameters
- * @param error [out] error code
- * @param nonblocking true for nonblocking socket
- * @param backlog listening backlog
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateServerSocket(const struct addrinfo *addr,
- int &error, bool nonblocking = true,
- int backlog = ATNetworkTool::DefaultBacklog);
-
- /* Creates server listening sockets
- * @param sockets [out] list of created server listening sockets
- * @param port listening port
- * @param error [out] error code
- * @param loopback true to listen only on loopback
- * @param nonblocking true for nonblocking sockets
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @param backlog listening backlog
- * @param one true if want create only one socket
- * @return int >=0 number of created server sockets, ==-1 on error
- */
- static int CreateServerSockets(ATSocketList &sockets, in_port_t port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog,
- bool one = false);
- static int CreateServerSockets(ATSocketList &sockets, const char *port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog,
- bool one = false);
-
- /* Creates one server listening socket
- * @param port listening port
- * @param error [out] error code
- * @param loopback true to listen only on loopback
- * @param nonblocking true for nonblocking sockets
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @param backlog listening backlog
- * @return int !=-1 socket, ==-1 on error
- */
- static int CreateServerSocket(in_port_t port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog);
- static int CreateServerSocket(const char *port,
- int &error,
- bool loopback = false, bool nonblocking = true,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0,
- int backlog = ATNetworkTool::DefaultBacklog);
-
- /* Connects to local socket
- * @param sock socket to connect to
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectToSocket(int sock,
- int &error, bool loopback = true,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to address
- * @param addr destination address parameters
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectSocket(struct addrinfo *addr,
- int &error, bool loopback = false);
-
- /* Connects to address
- * @param addr destination address
- * @param addrlen socket address length
- * @param error [out] error code
- * @param loopback true to use loopback, false to use any local address
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectSocket(const struct sockaddr *addr, socklen_t addrlen,
- int &error, bool loopback = false,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to address
- * @param hostname name of destination host
- * @param port destination port
- * @param error [out] error code
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int Connect(const char *host, in_port_t port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
- static int Connect(const char *host, const char *port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Connects to loopback port
- * @param port destination port
- * @param error [out] error code
- * @param family sockets expected family
- * @param socktype sockets type
- * @param protocol sockets protocol
- * @return int !=-1 socket, ==-1 on error
- */
- static int ConnectLoopback(in_port_t port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
- static int ConnectLoopback(const char *port,
- int &error,
- int family = ATNetworkTool::AF_XINETX,
- int socktype = SOCK_STREAM, int protocol = 0);
-
- /* Returns local port associated with socket
- * @param sock socket
- * @return unsigned int port number, or 0 - on error
- */
- static unsigned int GetLocalPort(int sock);
-
- /* Accepts connection on sockets - returns address or error
- * @param s socket accepting connection
- * @param address [out] peer address of accepted connection
- * @param error [out] error code
- * @param nonblocking true for nonblocking sockets
- * @return int !=-1 socket, ==-1 on error
- */
- static int Accept(int s, ATAddress &address,
- int &error, bool nonblocking = true);
-};
-
-#endif //_AT_NETWORK_TOOL_H_
-
diff --git a/usr/src/cmd/lms/tools/ATVersion.cpp b/usr/src/cmd/lms/tools/ATVersion.cpp
deleted file mode 100644
index 1cfdd48d6d..0000000000
--- a/usr/src/cmd/lms/tools/ATVersion.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "iatshareddata.h"
-#include "ATVersion.h"
-#include <cstring>
-#include <cstdlib>
-#include <cstdio>
-#include <climits>
-#include <cerrno>
-#include <fstream>
-#include <dirent.h>
-
-#define AT_VERSION_ARGUMENT "--version"
-#define AT_VERSION_MAXSIZE 40
-#define AT_APPNAME_MAXSIZE 15
-#define ATstr(s) ATname(s)
-#define ATname(s) #s
-#define AT_VERSION_OUT_FORMAT "Version: %." ATstr(AT_VERSION_MAXSIZE) "s\n"
-#define AT_VERSION_SCAN_FORMAT "Version: %" ATstr(AT_VERSION_MAXSIZE) "s"
-#define AT_PIDFILE_NAME_FORMAT IATSTATERUNDIR "/%." ATstr(AT_APPNAME_MAXSIZE) "s.pid"
-#define AT_DEF_PIDFILE_NAME_FORMAT "/var/run/%." ATstr(AT_APPNAME_MAXSIZE) "s.pid"
-#define AT_PROCSTAT_NAME_FORMAT "Name:\t%" ATstr(AT_APPNAME_MAXSIZE) "s\n"
-
-const std::string ATVersion::appSearchPath =
- "PATH='/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin' && ";
-
-bool ATVersion::ShowVersionIfArg(int argc, const char **argv, const char *versionStr)
-{
- if (1 < argc) {
- for (int i = 1; i < argc; i++) {
- if (0 == strncmp(argv[i], AT_VERSION_ARGUMENT, strlen(AT_VERSION_ARGUMENT))) {
- fprintf(stdout, AT_VERSION_OUT_FORMAT, versionStr);
- return true;
- }
- }
- }
- return false;
-}
-
-bool ATVersion::GetAppVersion(const char *appName, std::string &version)
-{
- std::list<unsigned long> pids;
-
- version = "";
- if (IsAppRunning(appName, pids)) {
- for (std::list<unsigned long>::iterator iter = pids.begin(); iter != pids.end(); iter++) {
- std::string path = GetAppPathByPid(*iter);
- if (!path.empty()) {
- version = GetProcessVersion(path);
- return true;
- }
- }
- }
- version = GetProcessVersion(ATVersion::appSearchPath + appName);
- if (version.empty()) {
- version = GetProcessVersion(appName);
- }
- return false;
-}
-
-std::string ATVersion::GetProcessVersion(std::string cmd)
-{
- if (cmd.empty()) {
- return "";
- }
-
- FILE *fp = popen((cmd + " " AT_VERSION_ARGUMENT " 2>/dev/null").c_str(), "r");
- if (fp) {
- char buf[AT_VERSION_MAXSIZE + 1];
- int res = fscanf(fp, AT_VERSION_SCAN_FORMAT, buf);
- buf[AT_VERSION_MAXSIZE] = '\0';
- pclose(fp);
- if (1 == res) {
- return buf;
- }
- }
- return "";
-}
-
-bool ATVersion::IsAppRunning(const char *appName, std::list<unsigned long> &pids)
-{
- struct dirent **namelist;
- FILE *stat;
- char name_str[AT_APPNAME_MAXSIZE + 1];
- int num_entries;
- char status_path[256];
- unsigned long pid;
- unsigned long selfpid = 0;
- bool res = false;
- int ret;
-
- pids.clear();
-
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), AT_PIDFILE_NAME_FORMAT, appName);
- std::ifstream pidf(status_path);
- if (pidf.is_open()) {
- pidf >> pid;
- pidf.close();
- if (!(GetAppPathByPid(pid).empty())) {
- pids.push_back(pid);
- return true;
- }
- }
-
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), AT_DEF_PIDFILE_NAME_FORMAT, appName);
- pidf.open(status_path);
- if (pidf.is_open()) {
- pidf >> pid;
- pidf.close();
- if (!(GetAppPathByPid(pid).empty())) {
- pids.push_back(pid);
- return true;
- }
- }
-
- num_entries = scandir("/proc", &namelist, 0, alphasort);
- if (num_entries < 0) {
- return false;
- }
-
- memset(status_path, '\0', sizeof(status_path));
- if (-1 != readlink("/proc/self", status_path, sizeof(status_path))) {
- selfpid = std::atol(status_path);
- }
-
- while (num_entries--) {
- char *pidstr = namelist[num_entries]->d_name;
- if ((pidstr) && (pidstr[0] > '0') && (pidstr[0] <= '9')) {
- pid = std::atol(pidstr);
- if (pid != selfpid) {
- /* for process name we check the 'status' entry */
- memset(status_path, '\0', sizeof(status_path));
- snprintf(status_path, sizeof(status_path), "/proc/%lu/status", pid);
- if (NULL != (stat = fopen(status_path, "r"))) {
- memset(name_str, '\0', sizeof(name_str));
- ret = fscanf(stat, AT_PROCSTAT_NAME_FORMAT, name_str);
- fclose(stat);
- if ((1 == ret) && (strncmp(name_str, appName, 15) == 0)) {
- pids.push_back(pid);
- res = true;
- }
- }
- }
- }
- free(namelist[num_entries]);
- }
- free(namelist);
-
- return res;
-}
-
-
-std::string ATVersion::GetAppPathByPid(unsigned long pid)
-{
- char path[256];
- char exe_buf[PATH_MAX];
-
- memset(path, '\0', sizeof(path));
- snprintf(path, sizeof(path), "/proc/%lu/exe", pid);
- memset(exe_buf, '\0', PATH_MAX);
- if (-1 == readlink(path, exe_buf, PATH_MAX)) {
- return "";
- }
-
- if (NULL != strstr(exe_buf, " (deleted)")) {
- return "";
- }
-
- return exe_buf;
-}
-
diff --git a/usr/src/cmd/lms/tools/ATVersion.h b/usr/src/cmd/lms/tools/ATVersion.h
deleted file mode 100644
index d312c9e45f..0000000000
--- a/usr/src/cmd/lms/tools/ATVersion.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef _AT_VERSION_TOOL_H_
-#define _AT_VERSION_TOOL_H_
-
-#include <string>
-#include <list>
-
-class ATVersion
-{
-public:
- /**
- function check if user requested version information to be displayed on std output
- and show version number
- @param argc Argument count
- @param argv Argument array
- @param versionStr Version string to be displayed
- @return bool true if version user requested version to be displayed
- false if version information was not displayed
- */
- static bool ShowVersionIfArg(int argc, const char **argv, const char *versionStr);
-
- /**
- function gets application version - if target application uses this class to show version
- @param appName application name
- @param version string returning version or empty string if version not determined
- @return true - if application is running, false - if not.
- */
- static bool GetAppVersion(const char *appName, std::string &version);
-
- /**
- function gets process version - if target application uses this class to show version
- @param cmd path to application
- @return string version or empty string if version not determined
- */
- static std::string GetProcessVersion(std::string cmd);
-
- /**
- Checks if an application is running in the system.
- @param app_name Application binary name (not including path).
- @param pids returned list of pids of searched application
- @return true - if application is running, false - if not.
- */
- static bool IsAppRunning(const char *app_name, std::list<unsigned long> &pids);
-
- /**
- Returns path associated with application with given PID. Note that to access this information for all processes
- the function must be called with elevated privileges.
- @param pid PID of application of interest.
- @return Application path if possible.
- Empty string if access is not possbile.
- NULL if the application isn't runnig.
- */
- static std::string GetAppPathByPid(unsigned long pid);
-
- static const std::string appSearchPath;
-};
-
-#endif /* _AT_VERSION_TOOL_H_ */
diff --git a/usr/src/cmd/lms/tools/daemonize.cpp b/usr/src/cmd/lms/tools/daemonize.cpp
deleted file mode 100644
index 39a37bf2de..0000000000
--- a/usr/src/cmd/lms/tools/daemonize.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef DAEMON
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cerrno>
-#include <csignal>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <pwd.h>
-
-#include "daemonize.h"
-
-static RETSIGTYPE child_handler(int signum)
-{
- switch (signum) {
- case SIGALRM:
- exit(EXIT_FAILURE);
- break;
- case SIGUSR1:
- exit(EXIT_SUCCESS);
- break;
- case SIGCHLD:
- exit(EXIT_FAILURE);
- break;
- }
-}
-
-void daemonize()
-{
- pid_t pid, sid, parent;
-
- /* Drop user if there is one, and we were run as root */
- if (getuid() == 0 || geteuid() == 0) {
- struct passwd *pw = getpwnam(RUN_AS_USER);
- if (pw) {
- //syslog(LOG_NOTICE, "setting user to " RUN_AS_USER);
- setuid(pw->pw_uid);
- }
- }
-
- /* Trap signals that we expect to recieve */
- signal(SIGCHLD, child_handler);
- signal(SIGUSR1, child_handler);
- signal(SIGALRM, child_handler);
-
- /* Fork off the parent process */
- pid = fork();
- if (pid < 0) {
- syslog(LOG_ERR, "unable to fork daemon, code=%d (%s)",
- errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- /* If we got a good PID, then we can exit the parent process. */
- if (pid > 0) {
-
- /* Wait for confirmation from the child via SIGTERM or SIGCHLD, or
- for two seconds to elapse (SIGALRM). pause() should not return. */
- alarm(2);
- pause();
-
- exit(EXIT_FAILURE);
- }
-
- /* At this point we are executing as the child process */
- parent = getppid();
-
- signal(SIGCHLD, SIG_DFL);
- signal(SIGUSR1, SIG_DFL);
- signal(SIGALRM, SIG_DFL);
- setTerminationHandler();
-
- /* Create a new SID for the child process */
- sid = setsid();
- if (sid < 0) {
- syslog(LOG_ERR,
- "unable to create a new session, code %d (%s)",
- errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* Change the current working directory. This prevents the current
- directory from being locked; hence not being able to remove it. */
- if ((chdir("/")) < 0) {
- syslog(LOG_ERR,
- "unable to change directory to %s, code %d (%s)",
- "/", errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- /* Redirect standard files to /dev/null */
- freopen("/dev/null", "r", stdin);
- freopen("/dev/null", "w", stdout);
- freopen("/dev/null", "w", stderr);
-
- /* Tell the parent process that we are A-okay */
- kill(parent, SIGUSR1);
-}
-
-#endif //DAEMON
-
diff --git a/usr/src/cmd/lms/tools/daemonize.h b/usr/src/cmd/lms/tools/daemonize.h
deleted file mode 100644
index eaa2179baf..0000000000
--- a/usr/src/cmd/lms/tools/daemonize.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __DAEMONIZE_H__
-#define __DAEMONIZE_H__
-
-/* Change this to the user under which to run */
-#define RUN_AS_USER "root"
-
-void setTerminationHandler();
-void daemonize();
-
-#endif
diff --git a/usr/src/cmd/lms/types.h b/usr/src/cmd/lms/types.h
deleted file mode 100644
index 36b9fd462b..0000000000
--- a/usr/src/cmd/lms/types.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-/**********************************************************************
-* *
-* Module Name: *
-* types.h *
-* *
-* Abstract: *
-* types for each OS are declared here. *
-* *
-**********************************************************************/
-
-#ifndef _TYPES_H_
-#define _TYPES_H_
-
-typedef char CHAR;
-typedef signed char INT8, *PINT8;
-typedef signed short INT16, *PINT16;
-typedef signed int INT32, *PINT32;
-typedef unsigned char UINT8, *PUINT8, UCHAR;
-typedef unsigned short UINT16, *PUINT16;
-typedef unsigned int UINT32, *PUINT32;
-
-#ifndef CONST
-#define CONST const
-#endif
-
-typedef unsigned long DWORD;
-typedef int BOOL;
-typedef unsigned char BYTE;
-typedef unsigned short WORD;
-typedef float FLOAT;
-typedef FLOAT *PFLOAT;
-typedef BOOL *PBOOL;
-typedef BOOL *LPBOOL;
-typedef BYTE *PBYTE;
-typedef BYTE *LPBYTE;
-typedef int *PINT;
-typedef int *LPINT;
-typedef WORD *PWORD;
-typedef WORD *LPWORD;
-typedef long *LPLONG;
-typedef DWORD *PDWORD;
-typedef DWORD *LPDWORD;
-typedef void *LPVOID;
-typedef CONST void *LPCVOID;
-
-typedef int INT;
-typedef unsigned int UINT;
-typedef unsigned int *PUINT;
-
-//
-// UNICODE (Wide Character) types
-//
-
-typedef unsigned short WCHAR;
-
-typedef WCHAR *PWCHAR, *LPWCH, *PWCH;
-typedef CONST WCHAR *LPCWCH, *PCWCH;
-typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR;
-typedef PWSTR *PZPWSTR;
-typedef CONST PWSTR *PCZPWSTR;
-typedef WCHAR *LPUWSTR, *PUWSTR;
-typedef CONST WCHAR *LPCWSTR, *PCWSTR;
-typedef PCWSTR *PZPCWSTR;
-typedef CONST WCHAR *LPCUWSTR, *PCUWSTR;
-
-//
-// ANSI (Multi-byte Character) types
-//
-typedef CHAR *PCHAR, *LPCH, *PCH;
-typedef CONST CHAR *LPCCH, *PCCH;
-
-typedef CHAR *NPSTR, *LPSTR, *PSTR;
-typedef PSTR *PZPSTR;
-typedef CONST PSTR *PCZPSTR;
-typedef CONST CHAR *LPCSTR, *PCSTR;
-typedef PCSTR *PZPCSTR;
-
-//
-// Neutral ANSI/UNICODE types and macros
-//
-#ifdef UNICODE
-
-#ifndef _TCHAR_DEFINED
-typedef WCHAR TCHAR, *PTCHAR;
-typedef WCHAR TBYTE, *PTBYTE;
-#define _TCHAR_DEFINED
-#endif /* !_TCHAR_DEFINED */
-
-typedef LPWSTR LPTCH, PTCH;
-typedef LPWSTR PTSTR, LPTSTR;
-typedef LPCWSTR PCTSTR, LPCTSTR;
-typedef LPUWSTR PUTSTR, LPUTSTR;
-typedef LPCUWSTR PCUTSTR, LPCUTSTR;
-typedef LPWSTR LP;
-#define __TEXT(quote) L##quote
-
-#else /* UNICODE */
-
-#ifndef _TCHAR_DEFINED
-typedef char TCHAR, *PTCHAR;
-typedef unsigned char TBYTE , *PTBYTE ;
-#define _TCHAR_DEFINED
-#endif /* !_TCHAR_DEFINED */
-
-typedef LPSTR LPTCH, PTCH;
-typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
-typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
-#define __TEXT(quote) quote
-
-#endif /* UNICODE */
-
-#define TEXT(quote) __TEXT(quote)
-
-#if defined(__sun) || defined(_LINUX)
-#define EVENTLOG_ERROR_TYPE LOG_ERR
-#define EVENTLOG_WARNING_TYPE LOG_WARNING
-#define EVENTLOG_INFORMATION_TYPE LOG_INFO
-
-#ifdef DEBUGLOG
-#if defined(__sun)
-#define PRINT(...) printf(__VA_ARGS__)
-#define ERROR(...) fprintf(stderr, __VA_ARGS__)
-#else // _LINUX
-#define PRINT(format, arg...) printf(format, ##arg)
-#define ERROR(format, arg...) fprintf(stderr, format, ##arg)
-#endif // __sun
-#else
-#if defined(__sun)
-#define PRINT(...)
-#define ERROR(...)
-#else // _LINUX
-#define PRINT(format, arg...)
-#define ERROR(format, arg...)
-#endif // __sun
-#endif //DEBUGLOG
-#endif // __sun || _LINUX
-
-#endif /* _TYPES_H_ */
diff --git a/usr/src/cmd/lms/version.h b/usr/src/cmd/lms/version.h
deleted file mode 100644
index 8c434e5abd..0000000000
--- a/usr/src/cmd/lms/version.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of Intel Corp. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *******************************************************************************/
-
-#ifndef __VERSION_H__
-#define __VERSION_H__
-
-#define MAJOR_VERSION 5
-#define MINOR_VERSION 0
-#define QUICK_FIX_NUMBER 0
-#define VER_BUILD 30
-
-#define _MAKE_VER_STRING(maj, min, submin, bld) #maj "." #min "." #submin "." #bld
-#define MAKE_VER_STRING(maj, min, submin, bld) _MAKE_VER_STRING(maj, min, submin, bld)
-
-#define VER_PRODUCTVERSION MAJOR_VERSION, MINOR_VERSION, QUICK_FIX_NUMBER, VER_BUILD
-#define VER_PRODUCTVERSION_STR MAKE_VER_STRING(MAJOR_VERSION, MINOR_VERSION, QUICK_FIX_NUMBER, VER_BUILD)
-
-#endif
diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile
index e4269ac0e2..543928c16b 100644
--- a/usr/src/man/man1m/Makefile
+++ b/usr/src/man/man1m/Makefile
@@ -13,7 +13,7 @@
# Copyright 2011, Richard Lowe
# Copyright 2016 Joyent, Inc.
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
include $(SRC)//Makefile.master
@@ -554,8 +554,7 @@ _MANFILES= 6to4relay.1m \
i386_MANFILES= \
acpidump.1m \
- acpixtract.1m \
- lms.1m
+ acpixtract.1m
sparc_MANFILES= cvcd.1m \
dcs.1m \
diff --git a/usr/src/man/man1m/lms.1m b/usr/src/man/man1m/lms.1m
deleted file mode 100644
index b6f2e2292b..0000000000
--- a/usr/src/man/man1m/lms.1m
+++ /dev/null
@@ -1,68 +0,0 @@
-'\" te
-.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
-.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
-.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH LMS 1M "Mar 3, 2009"
-.SH NAME
-lms \- allow applications to access the Intel Active Management Technology
-.SH SYNOPSIS
-.LP
-.nf
-\fBlms\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The Local Manageability Service, \fBlms\fR, allows applications to access the
-Intel Active Management Technology (Intel AMT) ME (Management Engine) using the
-local HECI interface. LMS is dependent on the HECI driver.
-.sp
-.LP
-To use \fBlms\fR, ensure that the Intel AMT Manageability Interface driver is
-installed and connected to the ME.
-.sp
-.LP
-\fBlms\fR is intended to be run as a daemon. Messages from the service are sent
-to the \fBsyslog\fR. LMS messages are marked with a source of \fB"LMS"\fR.
-.sp
-.LP
-For an example of how to enable the LMS service using SMF, see \fBEXAMPLES\fR.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fREnabling the LMS service using SMF
-.sp
-.LP
-The following example enables the LMS service using SMF:
-
-.sp
-.in +2
-.nf
-svcadm enable network/lms
-.fi
-.in -2
-.sp
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Architecture x86
-_
-Interface Stability Volatile
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBattributes\fR(5), \fBsmf\fR(5)
diff --git a/usr/src/man/man7d/Makefile b/usr/src/man/man7d/Makefile
index f9fc43097b..368319657a 100644
--- a/usr/src/man/man7d/Makefile
+++ b/usr/src/man/man7d/Makefile
@@ -14,7 +14,7 @@
# Copyright 2016 Garrett D'Amore <garrett@damore.org>
# Copyright (c) 2017, Joyent, Inc.
# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
include $(SRC)/Makefile.master
@@ -209,7 +209,6 @@ i386_MANFILES= ahci.7d \
dnet.7d \
ecpp.7d \
elxl.7d \
- heci.7d \
i40e.7d \
i915.7d \
ipmi.7d \
@@ -244,17 +243,17 @@ i386_MANFILES= ahci.7d \
zyd.7d
_MANLINKS= 1394.7d \
- allkmem.7d \
- bscbus.7d \
- fdc.7d \
- firewire.7d \
- i2bsc.7d \
- kmem.7d \
- lo0.7d \
- ticots.7d \
- ticotsord.7d \
- urandom.7d \
- usb.7d
+ allkmem.7d \
+ bscbus.7d \
+ fdc.7d \
+ firewire.7d \
+ i2bsc.7d \
+ kmem.7d \
+ lo0.7d \
+ ticots.7d \
+ ticotsord.7d \
+ urandom.7d \
+ usb.7d
sparc_MANLINKS= drmach.7d \
ngdr.7d \
diff --git a/usr/src/man/man7d/heci.7d b/usr/src/man/man7d/heci.7d
deleted file mode 100644
index c7361da8d0..0000000000
--- a/usr/src/man/man7d/heci.7d
+++ /dev/null
@@ -1,43 +0,0 @@
-'\" te
-.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
-.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the
-.\" fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH HECI 7D "Feb 24, 2009"
-.SH NAME
-heci \- Intel(R) AMT Manageability Interface Driver
-.SH DESCRIPTION
-.sp
-.LP
-The Intel AMT Manageability Interface driver allows applications to access the
-Intel Active Management Technology (Intel AMT) FW by way of the host interface
-(as opposed to a network interface).
-.sp
-.LP
-The Intel AMT Manageability Interface driver is meant to be used by the Local
-Manageability Service. When the Intel AMT machine is in Legacy Mode, the Intel
-AMT Manageability Interface driver functions. Messages from the Intel AMT
-Manageability Interface driver are sent to the system's log, that is,
-\fB/var/log/messages\fR.
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for a description of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-l | l
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Architecture x86
-_
-Interface Stability Volatile
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBlms\fR(1M), \fBattributes\fR(5), \fBe1000g\fR(7D), \fBiwk\fR(7D)
diff --git a/usr/src/pkg/manifests/system-management-intel-amt.mf b/usr/src/pkg/manifests/system-management-intel-amt.mf
index 06e3754c81..c5a47d5b30 100644
--- a/usr/src/pkg/manifests/system-management-intel-amt.mf
+++ b/usr/src/pkg/manifests/system-management-intel-amt.mf
@@ -23,57 +23,7 @@
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
-#
-# The default for payload-bearing actions in this package is to appear in the
-# global zone only. See the include file for greater detail, as well as
-# information about overriding the defaults.
-#
<include global_zone_only_component>
set name=pkg.fmri value=pkg:/system/management/intel-amt@$(PKGVERS)
-set name=pkg.description \
- value="Solaris support for Intel Active Management Technology"
-set name=pkg.summary value="Solaris support for Intel AMT"
-set name=info.classification \
- value="org.opensolaris.category.2008:System/Enterprise Management"
+set name=pkg.obsolete value=true
set name=variant.arch value=i386
-dir path=kernel group=sys
-dir path=kernel/drv group=sys
-dir path=kernel/drv/$(ARCH64) group=sys
-dir path=lib
-dir path=lib/svc
-dir path=lib/svc/manifest group=sys
-dir path=lib/svc/manifest/network group=sys
-dir path=lib/svc/method
-dir path=usr group=sys
-dir path=usr/lib
-dir path=usr/share/man
-dir path=usr/share/man/man1m
-dir path=usr/share/man/man7d
-driver name=heci perms="* 0644 root sys" \
- alias=pci8086,2974 \
- alias=pci8086,2984 \
- alias=pci8086,2994 \
- alias=pci8086,29a4 \
- alias=pci8086,29b4 \
- alias=pci8086,29c4 \
- alias=pci8086,2e04 \
- alias=pci8086,2e14
-file path=kernel/drv/$(ARCH64)/heci group=sys
-file path=kernel/drv/heci group=sys
-file path=lib/svc/manifest/network/lms.xml group=sys mode=0444
-file path=lib/svc/method/svc-lms mode=0555
-file path=usr/lib/lms mode=0555
-file path=usr/share/man/man1m/lms.1m
-file path=usr/share/man/man7d/heci.7d
-legacy pkg=SUNWamt \
- desc="Solaris support for Intel Active Management Technology" \
- name="Solaris support for Intel AMT"
-legacy pkg=SUNWamt-lms \
- desc="Solaris support for Intel Active Management Technology - LMS daemon" \
- name="Solaris support for Intel AMT - LMS daemon"
-license cr_Sun license=cr_Sun
-license lic_CDDL license=lic_CDDL
-license usr/src/cmd/lms/THIRDPARTYLICENSE \
- license=usr/src/cmd/lms/THIRDPARTYLICENSE
-license usr/src/uts/intel/io/heci/THIRDPARTYLICENSE \
- license=usr/src/uts/intel/io/heci/THIRDPARTYLICENSE
diff --git a/usr/src/uts/intel/Makefile.files b/usr/src/uts/intel/Makefile.files
index ca4eeb8c45..bc14731628 100644
--- a/usr/src/uts/intel/Makefile.files
+++ b/usr/src/uts/intel/Makefile.files
@@ -22,7 +22,7 @@
#
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, Joyent, Inc. All rights reserved.
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
#
@@ -154,13 +154,6 @@ RADEON_OBJS += r300_cmdbuf.o radeon_cp.o radeon_drv.o \
radeon_state.o radeon_irq.o radeon_mem.o
SD_OBJS += sd.o sd_xbuf.o
-HECI_OBJS += \
- heci_init.o \
- heci_intr.o \
- heci_interface.o \
- io_heci.o \
- heci_main.o
-
STRATEGY_OBJS += strategy.o
UCODE_OBJS += ucode_drv.o
VGATEXT_OBJS += vgatext.o vgasubr.o
diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel
index 1577747283..1d66ece1cd 100644
--- a/usr/src/uts/intel/Makefile.intel
+++ b/usr/src/uts/intel/Makefile.intel
@@ -23,7 +23,7 @@
# Copyright (c) 2013 Andrew Stormont. All rights reserved.
# Copyright 2016 Joyent, Inc.
# Copyright 2016 Garrett D'Amore <garrett@damore.org>
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
#
@@ -356,7 +356,6 @@ DRV_KMODS += ural
DRV_KMODS += uath
DRV_KMODS += urtw
DRV_KMODS += vgatext
-DRV_KMODS += heci
DRV_KMODS += vnic
DRV_KMODS += vscan
DRV_KMODS += wc
diff --git a/usr/src/uts/intel/Makefile.rules b/usr/src/uts/intel/Makefile.rules
index 2b21ba76c7..6806645dd5 100644
--- a/usr/src/uts/intel/Makefile.rules
+++ b/usr/src/uts/intel/Makefile.rules
@@ -22,7 +22,7 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# Copyright 2012 Joyent, Inc. All rights reserved.
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright 2017 Nexenta Systems, Inc.
#
#
@@ -234,10 +234,6 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/intel/io/vgatext/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
-$(OBJS_DIR)/%.o: $(UTSBASE)/intel/io/heci/%.c
- $(COMPILE.c) -o $@ $<
- $(CTFCONVERT_O)
-
$(OBJS_DIR)/%.o: $(UTSBASE)/intel/io/vmxnet3s/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
@@ -466,9 +462,6 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/intel/io/scsi/targets/%.c
$(LINTS_DIR)/%.ln: $(UTSBASE)/intel/io/vgatext/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
-$(LINTS_DIR)/%.ln: $(UTSBASE)/intel/io/heci/%.c
- @($(LHEAD) $(LINT.c) $< $(LTAIL))
-
$(LINTS_DIR)/%.ln: $(UTSBASE)/intel/io/vmxnet3s/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
diff --git a/usr/src/uts/intel/heci/Makefile b/usr/src/uts/intel/heci/Makefile
deleted file mode 100644
index b90d6e1736..0000000000
--- a/usr/src/uts/intel/heci/Makefile
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# intel architecture dependent
-#
-
-#
-# Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-# Define the module and object file sets.
-#
-MODULE = heci
-OBJECTS = $(HECI_OBJS:%=$(OBJS_DIR)/%)
-LINTS = $(HECI_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE)
-
-LDFLAGS += -dy
-#
-# Include common rules.
-#
-include $(UTSBASE)/intel/Makefile.intel
-
-#
-# Define targets
-#
-ALL_TARGET = $(BINARY)
-LINT_TARGET = $(MODULE).lint
-INSTALL_TARGET = $(BINARY) $(ROOTMODULE)
-
-#
-# Default build targets.
-#
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-#
-# we're not linting heci. Will revisit
-#
-
-lint: $(LINT_DEPS)
-
-modlintlib: $(MODLINTLIB_DEPS)
-
-clean.lint: $(CLEAN_LINT_DEPS)
-
-install: $(INSTALL_DEPS)
-
-#
-# Include common targets.
-#
-include $(UTSBASE)/intel/Makefile.targ
diff --git a/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE b/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE
deleted file mode 100644
index c94c8959ea..0000000000
--- a/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Part of "Intel(R) AMT Management Interface" Linux driver
- *
- * Copyright (c) 2003 - 2007 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
diff --git a/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE.descrip b/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE.descrip
deleted file mode 100644
index f5da5567dd..0000000000
--- a/usr/src/uts/intel/io/heci/THIRDPARTYLICENSE.descrip
+++ /dev/null
@@ -1 +0,0 @@
-Intel Management Engine Interface (Also known as HECI) driver
diff --git a/usr/src/uts/intel/io/heci/heci.h b/usr/src/uts/intel/io/heci/heci.h
deleted file mode 100644
index f2f2bb9d32..0000000000
--- a/usr/src/uts/intel/io/heci/heci.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#ifndef _HECI_H_
-#define _HECI_H_
-
-
-extern const struct guid heci_pthi_guid;
-extern const struct guid heci_wd_guid;
-extern const uint8_t start_wd_params[];
-extern const uint8_t stop_wd_params[];
-extern const uint8_t heci_wd_state_independence_msg[3][4];
-
-/*
- * heci device ID
- */
-#define HECI_DEV_ID_82946GZ 0x2974 /* 82946GZ/GL */
-#define HECI_DEV_ID_82G35 0x2984 /* 82G35 Express */
-#define HECI_DEV_ID_82Q965 0x2994 /* 82Q963/Q965 */
-#define HECI_DEV_ID_82G965 0x29A4 /* 82P965/G965 */
-
-#define HECI_DEV_ID_82GM965 0x2A04 /* Mobile PM965/GM965 */
-#define HECI_DEV_ID_82GME965 0x2A14 /* Mobile GME965/GLE960 */
-
-#define HECI_DEV_ID_ICH9_82Q35 0x29B4 /* 82Q35 Express */
-#define HECI_DEV_ID_ICH9_82G33 0x29C4 /* 82G33/G31/P35/P31 Express */
-#define HECI_DEV_ID_ICH9_82Q33 0x29D4 /* 82Q33 Express */
-#define HECI_DEV_ID_ICH9_82X38 0x29E4 /* 82X38/X48 Express */
-#define HECI_DEV_ID_ICH9_3200 0x29F4 /* 3200/3210 Server */
-
-#define HECI_DEV_ID_ICH9_6 0x28B4 /* Bearlake */
-#define HECI_DEV_ID_ICH9_7 0x28C4 /* Bearlake */
-#define HECI_DEV_ID_ICH9_8 0x28D4 /* Bearlake */
-#define HECI_DEV_ID_ICH9_9 0x28E4 /* Bearlake */
-#define HECI_DEV_ID_ICH9_10 0x28F4 /* Bearlake */
-
-#define HECI_DEV_ID_ICH9M_1 0x2A44 /* Cantiga */
-#define HECI_DEV_ID_ICH9M_2 0x2A54 /* Cantiga */
-#define HECI_DEV_ID_ICH9M_3 0x2A64 /* Cantiga */
-#define HECI_DEV_ID_ICH9M_4 0x2A74 /* Cantiga */
-
-#define HECI_DEV_ID_ICH10_1 0x2E04 /* Eaglelake */
-#define HECI_DEV_ID_ICH10_2 0x2E14 /* Eaglelake */
-#define HECI_DEV_ID_ICH10_3 0x2E24 /* Eaglelake */
-#define HECI_DEV_ID_ICH10_4 0x2E34 /* Eaglelake */
-
-/*
- * heci init function prototypes
- */
-void init_heci_device(dev_info_t *dip,
- struct iamt_heci_device *device);
-void fini_heci_device(struct iamt_heci_device *device);
-void heci_reset(struct iamt_heci_device *dev, int interrupts);
-int heci_hw_init(struct iamt_heci_device *dev);
-void heci_task_initialize_clients(void *data);
-int heci_initialize_clients(struct iamt_heci_device *dev);
-struct heci_file_private *heci_alloc_file_private(struct heci_file *file);
-int heci_disconnect_host_client(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-void heci_initialize_list(struct io_heci_list *list,
- struct iamt_heci_device *dev);
-void heci_flush_list(struct io_heci_list *list,
- struct heci_file_private *file_ext);
-void heci_flush_queues(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-
-void heci_remove_client_from_file_list(struct iamt_heci_device *dev,
- uint8_t host_client_id);
-
-/*
- * interrupt function prototype
- */
-uint_t heci_isr_interrupt(caddr_t);
-
-void heci_wd_timer(void *data);
-
-/*
- * input output function prototype
- */
-int heci_ioctl_get_version(struct iamt_heci_device *device, int if_num,
- struct heci_message_data *u_msg, struct heci_message_data k_msg,
- struct heci_file_private *file_ext,
- int mode);
-
-int heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
- struct heci_message_data *u_msg, struct heci_message_data k_msg,
- struct heci_file *file, int mode);
-
-int heci_ioctl_wd(struct iamt_heci_device *device, int if_num,
- struct heci_message_data k_msg,
- struct heci_file_private *file_ext, int mode);
-
-int heci_ioctl_bypass_wd(struct iamt_heci_device *device, int if_num,
- struct heci_message_data k_msg,
- struct heci_file_private *file_ext, int mode);
-
-int heci_start_read(struct iamt_heci_device *device, int if_num,
- struct heci_file_private *file_ext);
-
-int pthi_write(struct iamt_heci_device *device,
- struct heci_cb_private *priv_cb);
-
-int pthi_read(struct iamt_heci_device *device, int if_num,
- struct heci_file *file, struct uio *uio_p);
-
-struct heci_cb_private *find_pthi_read_list_entry(
- struct iamt_heci_device *device, struct heci_file *file);
-
-void run_next_iamthif_cmd(struct iamt_heci_device *device);
-
-void heci_free_cb_private(struct heci_cb_private *priv_cb);
-
-void heci_free_file_private(struct heci_file_private *priv);
-
-#endif /* _HECI_H_ */
diff --git a/usr/src/uts/intel/io/heci/heci_data_structures.h b/usr/src/uts/intel/io/heci/heci_data_structures.h
deleted file mode 100644
index 4c207df1d7..0000000000
--- a/usr/src/uts/intel/io/heci/heci_data_structures.h
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#ifndef _HECI_DATA_STRUCTURES_H_
-#define _HECI_DATA_STRUCTURES_H_
-
-#include <sys/varargs.h>
-#include <sys/types.h>
-
-#ifndef SUNOS
-#define SUNOS
-#endif
-
-/*
- * error code definition
- */
-#define ESLOTS_OVERFLOW 1
-#define ECORRUPTED_MESSAGE_HEADER 1000
-#define ECOMPLETE_MESSAGE 1001
-
-#define HECI_FC_MESSAGE_RESERVED_LENGTH 5
-
-/*
- * Number of queue lists used by this driver
- */
-#define HECI_IO_LISTS_NUMBER 7
-
-/*
- * Maximum transmission unit (MTU) of heci messages
- */
-#define IAMTHIF_MTU 4160
-#pragma pack(1)
-
-
-/*
- * HECI HW Section
- */
-
-/* HECI registers */
-/* H_CB_WW - Host Circular Buffer (CB) Write Window register */
-#define H_CB_WW 0
-/* H_CSR - Host Control Status register */
-#define H_CSR 4
-/* ME_CB_RW - ME Circular Buffer Read Window register (read only) */
-#define ME_CB_RW 8
-/* ME_CSR_HA - ME Control Status Host Access register (read only) */
-#define ME_CSR_HA 0xC
-
-
-/* register bits of H_CSR (Host Control Status register) */
-/* Host Circular Buffer Depth - maximum number of 32-bit entries in CB */
-#define H_CBD 0xFF000000
-/* Host Circular Buffer Write Pointer */
-#define H_CBWP 0x00FF0000
-/* Host Circular Buffer Read Pointer */
-#define H_CBRP 0x0000FF00
-/* Host Reset */
-#define H_RST 0x00000010
-/* Host Ready */
-#define H_RDY 0x00000008
-/* Host Interrupt Generate */
-#define H_IG 0x00000004
-/* Host Interrupt Status */
-#define H_IS 0x00000002
-/* Host Interrupt Enable */
-#define H_IE 0x00000001
-
-
-/*
- * register bits of ME_CSR_HA (ME Control Status Host Access register)
- * ME CB (Circular Buffer) Depth HRA (Host Read Access)
- * - host read only access to ME_CBD
- */
-#define ME_CBD_HRA 0xFF000000
-/* ME CB Write Pointer HRA - host read only access to ME_CBWP */
-#define ME_CBWP_HRA 0x00FF0000
-/* ME CB Read Pointer HRA - host read only access to ME_CBRP */
-#define ME_CBRP_HRA 0x0000FF00
-/* ME Reset HRA - host read only access to ME_RST */
-#define ME_RST_HRA 0x00000010
-/* ME Ready HRA - host read only access to ME_RDY */
-#define ME_RDY_HRA 0x00000008
-/* ME Interrupt Generate HRA - host read only access to ME_IG */
-#define ME_IG_HRA 0x00000004
-/* ME Interrupt Status HRA - host read only access to ME_IS */
-#define ME_IS_HRA 0x00000002
-/* ME Interrupt Enable HRA - host read only access to ME_IE */
-#define ME_IE_HRA 0x00000001
-
-#define HECI_MINOR_NUMBER 1
-/* #define HECI_PTHI_MINOR_NUMBER 0 */
-#define MAKE_MINOR_NUM(minor, instance) (((uint_t)(minor) << 8) \
- | ((instance) & 0xFF))
-#define HECI_MINOR_TO_INSTANCE(x) ((x) & 0xFF)
-#define HECI_MINOR_TO_IFNUM(x) (((x) >> 8) & 0xFF)
-
-#define HECI_MAX_OPEN_HANDLE_COUNT 253
-
-/*
- * debug kernel print macro define
- */
-#define PRN(...) _PRN("%s(): "__VA_ARGS__, "")
-#define _PRN(format, ...) \
- cmn_err(CE_CONT, format"%s", __func__, __VA_ARGS__)
-
-#ifdef DEBUG
-extern int heci_debug;
-#define DBG(...) { if (heci_debug) PRN(__VA_ARGS__); }
-#else
-#define DBG
-#endif
-
-#define assert(expr) \
- if (!(expr)) { \
- cmn_err(CE_WARN, "Assertion failed! %s,%s,line=%d", #expr, \
- __FILE__, __LINE__); \
- }
-
-#define list_next(p) ((p)->list_next)
-
-#define walk_list(p, n, h) \
- for (p = list_next(h), n = list_next(p); \
- p != (h); \
- p = n, n = list_next(p))
-
-
-#define list_init(ptr) { \
- (ptr)->list_next = (ptr); (ptr)->list_prev = (ptr); \
-}
-
-#define LIST_INIT_HEAD list_init
-#define list_del_init(n) { \
- list_del(n); \
- list_init(n); \
- }
-
-#define list_empty(l) ((l)->list_next == (l))
-#define list_del(p) { (p)->list_next->list_prev = (p)->list_prev; \
- (p)->list_prev->list_next = (p)->list_next; }
-#define list_add_tail(newnode, head) { \
- (head)->list_prev->list_next = (newnode); \
- (newnode)->list_prev = (head)->list_prev; \
- (head)->list_prev = (newnode); \
- (newnode)->list_next = (head); \
- }
-#define list_relink_node(newnode, head) { \
- list_del(newnode); \
- list_add_tail(newnode, head); \
- }
-
-#ifdef __GNUC__
-
-#define find_struct(ptr, type, member) ( \
- { \
- const __typeof(((type *)0)->member) *__tmpp = (ptr); \
- (type *)(void *)((char *)__tmpp - ((size_t)&((type *)0)->member)); \
- })
-#else
-/* type unsafe version */
-#define find_struct(ptr, type, member) \
- ((type *)(void *)((char *)(ptr) \
- - ((size_t)&((type *)0)->member)))
-
-#endif
-
-#define list_for_each_entry_safe(pos, n, head, member, type) \
- for (pos = find_struct((head)->list_next, type, member), \
- n = find_struct(pos->member.list_next, type, member); \
- &pos->member != (head); \
- pos = n, n = find_struct(n->member.list_next, type, member))
-
-#define HZ drv_usectohz(1000000)
-/*
- * time to wait HECI become ready after init
- */
-#define HECI_INTEROP_TIMEOUT (HZ * 7)
-
-/*
- * watch dog definition
- */
-#define HECI_WATCHDOG_DATA_SIZE 16
-#define HECI_START_WD_DATA_SIZE 20
-#define HECI_WD_PARAMS_SIZE 4
-#define HECI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
-
-#define HECI_WD_HOST_CLIENT_ID 1
-#define HECI_IAMTHIF_HOST_CLIENT_ID 2
-
-struct guid {
- uint32_t data1;
- uint16_t data2;
- uint16_t data3;
- uint8_t data4[8];
-};
-
-/* File state */
-enum file_state {
- HECI_FILE_INITIALIZING = 0,
- HECI_FILE_CONNECTING,
- HECI_FILE_CONNECTED,
- HECI_FILE_DISCONNECTING,
- HECI_FILE_DISCONNECTED
-};
-
-/* HECI device states */
-enum heci_states {
- HECI_INITIALIZING = 0,
- HECI_ENABLED,
- HECI_RESETING,
- HECI_DISABLED,
- HECI_RECOVERING_FROM_RESET,
- HECI_POWER_DOWN,
- HECI_POWER_UP
-};
-
-enum iamthif_states {
- HECI_IAMTHIF_IDLE,
- HECI_IAMTHIF_WRITING,
- HECI_IAMTHIF_FLOW_CONTROL,
- HECI_IAMTHIF_READING,
- HECI_IAMTHIF_READ_COMPLETE
-};
-
-enum heci_file_transaction_states {
- HECI_IDLE,
- HECI_WRITING,
- HECI_WRITE_COMPLETE,
- HECI_FLOW_CONTROL,
- HECI_READING,
- HECI_READ_COMPLETE
-};
-
-/* HECI CB */
-enum heci_cb_major_types {
- HECI_READ = 0,
- HECI_WRITE,
- HECI_IOCTL,
- HECI_OPEN,
- HECI_CLOSE
-};
-
-/* HECI user data struct */
-struct heci_message_data {
- uint32_t size;
- char *data;
-#ifndef _LP64
- char *pad;
-#endif
-};
-
-#define HECI_CONNECT_TIMEOUT 3 /* at least 2 seconds */
-
-#define IAMTHIF_STALL_TIMER 12 /* seconds */
-#define IAMTHIF_READ_TIMER 15 /* seconds */
-struct heci_file {
- void * private_data;
-};
-
-struct heci_cb_private {
- struct list_node cb_list;
- enum heci_cb_major_types major_file_operations;
- void *file_private;
- struct heci_message_data request_buffer;
- struct heci_message_data response_buffer;
- unsigned long information;
- unsigned long read_time;
- struct heci_file *file_object;
-};
-
-
-struct io_heci_list {
- struct heci_cb_private heci_cb;
- int status;
- struct iamt_heci_device *device_extension;
-};
-
-struct heci_driver_version {
- uint8_t major;
- uint8_t minor;
- uint8_t hotfix;
- uint16_t build;
-};
-
-struct heci_client {
- uint32_t max_message_length;
- uint8_t protocol_version;
-};
-
-/*
- * HECI BUS Interface Section
- */
-struct heci_msg_hdr {
- uint32_t me_addr:8;
- uint32_t host_addr:8;
- uint32_t length:9;
- uint32_t reserved:6;
- uint32_t msg_complete:1;
-};
-
-
-struct hbm_cmd {
- uint8_t cmd:7;
- uint8_t is_response:1;
-};
-
-
-struct heci_bus_message {
- struct hbm_cmd cmd;
- uint8_t command_specific_data[];
-};
-
-struct hbm_version {
- uint8_t minor_version;
- uint8_t major_version;
-};
-
-struct hbm_host_version_request {
- struct hbm_cmd cmd;
- uint8_t reserved;
- struct hbm_version host_version;
-};
-
-struct hbm_host_version_response {
- struct hbm_cmd cmd;
- int host_version_supported;
- struct hbm_version me_max_version;
-};
-
-struct hbm_host_stop_request {
- struct hbm_cmd cmd;
- uint8_t reason;
- uint8_t reserved[2];
-};
-
-struct hbm_host_stop_response {
- struct hbm_cmd cmd;
- uint8_t reserved[3];
-};
-
-struct hbm_me_stop_request {
- struct hbm_cmd cmd;
- uint8_t reason;
- uint8_t reserved[2];
-};
-
-struct hbm_host_enum_request {
- struct hbm_cmd cmd;
- uint8_t reserved[3];
-};
-
-struct hbm_host_enum_response {
- struct hbm_cmd cmd;
- uint8_t reserved[3];
- uint8_t valid_addresses[32];
-};
-
-struct heci_client_properties {
- struct guid protocol_name;
- uint8_t protocol_version;
- uint8_t max_number_of_connections;
- uint8_t fixed_address;
- uint8_t single_recv_buf;
- uint32_t max_msg_length;
-};
-
-struct hbm_props_request {
- struct hbm_cmd cmd;
- uint8_t address;
- uint8_t reserved[2];
-};
-
-
-struct hbm_props_response {
- struct hbm_cmd cmd;
- uint8_t address;
- uint8_t status;
- uint8_t reserved[1];
- struct heci_client_properties client_properties;
-};
-
-struct hbm_client_connect_request {
- struct hbm_cmd cmd;
- uint8_t me_addr;
- uint8_t host_addr;
- uint8_t reserved;
-};
-
-struct hbm_client_connect_response {
- struct hbm_cmd cmd;
- uint8_t me_addr;
- uint8_t host_addr;
- uint8_t status;
-};
-
-struct hbm_client_disconnect_request {
- struct hbm_cmd cmd;
- uint8_t me_addr;
- uint8_t host_addr;
- uint8_t reserved[1];
-};
-
-struct hbm_flow_control {
- struct hbm_cmd cmd;
- uint8_t me_addr;
- uint8_t host_addr;
- uint8_t reserved[HECI_FC_MESSAGE_RESERVED_LENGTH];
-};
-
-struct heci_me_client {
- struct heci_client_properties props;
- uint8_t client_id;
- uint8_t flow_ctrl_creds;
-};
-
-#pragma pack()
-/* Private file struct */
-struct heci_file_private {
- struct list_node link;
- struct heci_file *file;
- enum file_state state;
- struct pollhead tx_pollwait;
- kcondvar_t rx_wait;
- struct pollhead pollwait;
- kmutex_t file_lock;
- kmutex_t read_io_lock;
- kmutex_t write_io_lock;
- int read_pending;
- int status;
- /* ID of client connected */
- uint8_t host_client_id;
- uint8_t me_client_id;
- uint8_t flow_ctrl_creds;
- uint8_t timer_count;
- enum heci_file_transaction_states reading_state;
- enum heci_file_transaction_states writing_state;
- int sm_state;
- struct heci_cb_private *read_cb;
-};
-
-/* private device struct */
-struct iamt_heci_device {
- dev_info_t *dip;
- ddi_acc_handle_t io_handle;
- ddi_iblock_cookie_t sc_iblk;
-
- /*
- * lists of queues
- */
-
- /* array of pointers to aio lists */
- struct io_heci_list *io_list_array[HECI_IO_LISTS_NUMBER];
- struct io_heci_list read_list; /* driver read queue */
- struct io_heci_list write_list; /* driver write queue */
- struct io_heci_list write_waiting_list; /* write waiting queue */
- struct io_heci_list ctrl_wr_list; /* managed write IOCTL list */
- struct io_heci_list ctrl_rd_list; /* managed read IOCTL list */
- struct io_heci_list pthi_cmd_list; /* PTHI list for cmd waiting */
-
- /* driver managed PTHI list for reading completed pthi cmd data */
- struct io_heci_list pthi_read_complete_list;
- /*
- * list of files
- */
- struct list_node file_list;
- /*
- * memory of device
- */
- char *mem_addr;
- /*
- * lock for the device
- */
- kmutex_t device_lock;
- ddi_taskq_t *work;
- int recvd_msg;
-
- ddi_taskq_t *reinit_tsk;
- timeout_id_t wd_timer;
- /*
- * hw states of host and fw(ME)
- */
- uint32_t host_hw_state;
- uint32_t me_hw_state;
- /*
- * waiting queue for receive message from FW
- */
- kcondvar_t wait_recvd_msg;
- kcondvar_t wait_stop_wd;
- /*
- * heci device states
- */
- enum heci_states heci_state;
- int stop;
-
- uint32_t extra_write_index;
- uint32_t rd_msg_buf[128]; /* used for control messages */
- uint32_t wr_msg_buf[128]; /* used for control messages */
- uint32_t ext_msg_buf[8]; /* for control responses */
- uint32_t rd_msg_hdr;
-
- struct hbm_version version;
-
- int host_buffer_is_empty;
- struct heci_file_private wd_file_ext;
- struct heci_me_client *me_clients; /* Note: need to be allocated */
- uint8_t heci_me_clients[32]; /* list of existing clients */
- uint8_t num_heci_me_clients;
- uint8_t heci_host_clients[32]; /* list of existing clients */
- uint8_t current_host_client_id;
-
- int wd_pending;
- int wd_stoped;
- uint16_t wd_timeout; /* seconds ((wd_data[1] << 8) + wd_data[0]) */
- unsigned char wd_data[HECI_START_WD_DATA_SIZE];
-
-
- uint16_t wd_due_counter;
- int asf_mode;
- int wd_bypass; /* if 1, don't refresh watchdog ME client */
-
- struct heci_file *iamthif_file_object;
- struct heci_file_private iamthif_file_ext;
- int iamthif_ioctl;
- int iamthif_canceled;
- uint32_t iamthif_timer;
- uint32_t iamthif_stall_timer;
- struct heci_file files[256]; /* a file handle for each client */
- unsigned char iamthif_msg_buf[IAMTHIF_MTU];
- uint32_t iamthif_msg_buf_size;
- uint32_t iamthif_msg_buf_index;
- int iamthif_flow_control_pending;
- enum iamthif_states iamthif_state;
-
- struct heci_cb_private *iamthif_current_cb;
- uint8_t write_hang;
- int need_reset;
- long open_handle_count;
-
-};
-
-/*
- * read_heci_register - Read a byte from the heci device
- *
- * @device: the device structure
- * @offset: offset from which to read the data
- *
- * @return the byte read.
- */
-uint32_t read_heci_register(struct iamt_heci_device *device,
- unsigned long offset);
-
-/*
- * write_heci_register - Write 4 bytes to the heci device
- *
- * @device: the device structure
- * @offset: offset from which to write the data
- * @value: the byte to write
- */
-void write_heci_register(struct iamt_heci_device *device, unsigned long offset,
- uint32_t value);
-
-#define UIO_OFFSET(p) (((struct uio *)p)->uio_offset)
-#define UIO_LENGTH(p) (((struct uio *)p)->uio_resid)
-#define UIO_BUFF(p) ((char *)((struct uio *)p)->uio_iov->iov_base)
-
-#endif /* _HECI_DATA_STRUCTURES_H_ */
diff --git a/usr/src/uts/intel/io/heci/heci_init.c b/usr/src/uts/intel/io/heci/heci_init.c
deleted file mode 100644
index 0f5e4da22f..0000000000
--- a/usr/src/uts/intel/io/heci/heci_init.c
+++ /dev/null
@@ -1,1203 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/ddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/devops.h>
-#include <sys/instance.h>
-#include <sys/modctl.h>
-#include <sys/open.h>
-#include <sys/stat.h>
-#include <sys/sunddi.h>
-#include <sys/sunndi.h>
-#include <sys/systm.h>
-#include <sys/mkdev.h>
-#include <sys/list.h>
-#include <sys/note.h>
-#include "heci_data_structures.h"
-#include "heci_interface.h"
-#include "heci.h"
-
-
-const uint8_t watch_dog_data[] = {
- 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
-};
-const uint8_t start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
-const uint8_t stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
-
-const uint8_t heci_wd_state_independence_msg[3][4] = {
- {0x05, 0x02, 0x51, 0x10},
- {0x05, 0x02, 0x52, 0x10},
- {0x07, 0x02, 0x01, 0x10}
-};
-
-const struct guid heci_asf_guid = {
- 0x75B30CD6, 0xA29E, 0x4AF7,
- {0xA7, 0x12, 0xE6, 0x17, 0x43, 0x93, 0xC8, 0xA6}
-};
-const struct guid heci_wd_guid = {
- 0x05B79A6F, 0x4628, 0x4D7F,
- {0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB}
-};
-const struct guid heci_pthi_guid = {
- 0x12f80028, 0xb4b7, 0x4b2d,
- {0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c}
-};
-
-
-/*
- * heci init function prototypes
- */
-static void heci_check_asf_mode(struct iamt_heci_device *dev);
-static int host_start_message(struct iamt_heci_device *dev);
-static int host_enum_clients_message(struct iamt_heci_device *dev);
-static int allocate_me_clients_storage(struct iamt_heci_device *dev);
-static void host_init_wd(struct iamt_heci_device *dev);
-static void host_init_iamthif(struct iamt_heci_device *dev);
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2);
-
-
-
-/*
- * heci_initialize_list - Sets up a queue list.
- *
- * @list: An instance of our list structure
- * @dev: Device object for our driver
- */
-void
-heci_initialize_list(struct io_heci_list *list,
- struct iamt_heci_device *dev)
-{
- /* initialize our queue list */
- LIST_INIT_HEAD(&list->heci_cb.cb_list);
- list->status = 0;
- list->device_extension = dev;
-}
-
-/*
- * heci_flush_queues - flush our queues list belong to file_ext.
- *
- * @dev: Device object for our driver
- * @file_ext: private data of the file object
- *
- */
-void
-heci_flush_queues(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- int i;
-
- if (!dev || !file_ext)
- return;
-
- /* flush our queue list belong to file_ext */
- for (i = 0; i < HECI_IO_LISTS_NUMBER; i++) {
- DBG("remove list entry belong to file_ext\n");
- heci_flush_list(dev->io_list_array[i], file_ext);
- }
-}
-
-
-/*
- * heci_flush_list - remove list entry belong to file_ext.
- *
- * @list: An instance of our list structure
- * @file_ext: private data of the file object
- */
-void
-heci_flush_list(struct io_heci_list *list,
- struct heci_file_private *file_ext)
-{
- struct heci_file_private *file_ext_tmp;
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
-
- if (!list || !file_ext)
- return;
-
- if (list->status != 0)
- return;
-
- if (list_empty(&list->heci_cb.cb_list))
- return;
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &list->heci_cb.cb_list, cb_list, struct heci_cb_private) {
- if (priv_cb_pos) {
- file_ext_tmp = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if (file_ext_tmp) {
- if (heci_fe_same_id(file_ext, file_ext_tmp))
- list_del(&priv_cb_pos->cb_list);
- }
- }
- }
-}
-
-/*
- * heci_reset_iamthif_params - initializes heci device iamthif
- * @dev: The heci device structure
- */
-static void heci_reset_iamthif_params(struct iamt_heci_device *dev)
-{
- /* reset iamthif parameters. */
- dev->iamthif_current_cb = NULL;
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = 0;
- dev->iamthif_file_ext.file = NULL;
- dev->iamthif_ioctl = 0;
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
-}
-
-/*
- * fini_heci_device - release resources allocated in init_heci_device()
- */
-void
-fini_heci_device(struct iamt_heci_device *device)
-{
- mutex_destroy(&device->device_lock);
- cv_destroy(&device->wait_recvd_msg);
- cv_destroy(&device->wait_stop_wd);
- if (device->work)
- ddi_taskq_destroy(device->work);
- if (device->reinit_tsk)
- ddi_taskq_destroy(device->reinit_tsk);
-
-}
-
-/*
- * init_heci_device - initializes the heci device structure
- *
- */
-void
-init_heci_device(dev_info_t *dip,
- struct iamt_heci_device *device)
-{
- int i;
-
- if (!device)
- return;
-
- /* setup our list array */
- device->io_list_array[0] = &device->read_list;
- device->io_list_array[1] = &device->write_list;
- device->io_list_array[2] = &device->write_waiting_list;
- device->io_list_array[3] = &device->ctrl_wr_list;
- device->io_list_array[4] = &device->ctrl_rd_list;
- device->io_list_array[5] = &device->pthi_cmd_list;
- device->io_list_array[6] = &device->pthi_read_complete_list;
- LIST_INIT_HEAD(&device->file_list);
- LIST_INIT_HEAD(&device->wd_file_ext.link);
- LIST_INIT_HEAD(&device->iamthif_file_ext.link);
- mutex_init(&device->device_lock, NULL, MUTEX_DRIVER, NULL);
- cv_init(&device->wait_recvd_msg, NULL, CV_DRIVER, NULL);
- cv_init(&device->wait_stop_wd, NULL, CV_DRIVER, NULL);
- device->open_handle_count = 0;
- device->num_heci_me_clients = 0;
- device->extra_write_index = 0;
- device->rd_msg_hdr = 0;
- device->mem_addr = NULL;
- device->asf_mode = B_FALSE;
- device->need_reset = B_FALSE;
- device->recvd_msg = B_FALSE;
- device->heci_state = HECI_INITIALIZING;
- device->iamthif_state = HECI_IAMTHIF_IDLE;
-
- device->work = ddi_taskq_create(dip, "heci_bh_handler", 1,
- TASKQ_DEFAULTPRI, 0);
- if (device->work == NULL)
- cmn_err(CE_WARN, "taskq_create failed for heci_bh_handler");
- device->reinit_tsk = ddi_taskq_create(dip, "heci_reinit_tsk", 1,
- TASKQ_DEFAULTPRI, 0);
- if (device->reinit_tsk == NULL)
- cmn_err(CE_WARN, "taskq_create failed for reinit_tsk");
-
- device->wd_pending = B_FALSE;
- device->wd_stoped = B_FALSE;
-
- device->me_clients = NULL;
- for (i = 0; i < HECI_IO_LISTS_NUMBER; i++)
- heci_initialize_list(device->io_list_array[i], device);
- device->dip = dip;
-}
-
-/*
- * heci_hw_init - init host and fw to start work.
- *
- * @dev: Device object for our driver
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_hw_init(struct iamt_heci_device *dev)
-{
- int err = 0;
-
- mutex_enter(&dev->device_lock);
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
- DBG("host_hw_state = 0x%08x, mestate = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- if ((dev->host_hw_state & H_IS) == H_IS) {
- /* acknowledge interrupt and stop interupts */
- heci_set_csr_register(dev);
- }
- dev->recvd_msg = 0;
- DBG("reset in start the heci device.\n");
-
- heci_reset(dev, 1);
-
- DBG("host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- /* wait for ME to turn on ME_RDY */
- err = 0;
- while (!dev->recvd_msg && err != -1) {
- err = cv_reltimedwait(&dev->wait_recvd_msg,
- &dev->device_lock, HECI_INTEROP_TIMEOUT, TR_CLOCK_TICK);
- }
-
- if (err == -1 && !dev->recvd_msg) {
- dev->heci_state = HECI_DISABLED;
- DBG("wait_event_interruptible_timeout failed"
- "on wait for ME to turn on ME_RDY.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- } else {
- if (!(((dev->host_hw_state & H_RDY) == H_RDY) &&
- ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) {
- dev->heci_state = HECI_DISABLED;
- DBG("host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state,
- dev->me_hw_state);
-
- if (!(dev->host_hw_state & H_RDY) != H_RDY)
- DBG("host turn off H_RDY.\n");
-
- if (!(dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
- DBG("ME turn off ME_RDY.\n");
-
- cmn_err(CE_WARN,
- "heci: link layer initialization failed.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- }
- dev->recvd_msg = 0;
- DBG("host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
- DBG("ME turn on ME_RDY and host turn on H_RDY.\n");
- DBG("heci: link layer has been established.\n");
- mutex_exit(&dev->device_lock);
- return (0);
-}
-
-/*
- * heci_hw_reset - reset fw via heci csr register.
- *
- * @dev: Device object for our driver
- * @interrupts: if interrupt should be enable after reset.
- */
-static void heci_hw_reset(struct iamt_heci_device *dev, int interrupts)
-{
- dev->host_hw_state |= (H_RST | H_IG);
-
- if (interrupts)
- heci_csr_enable_interrupts(dev);
- else
- heci_csr_disable_interrupts(dev);
-
-}
-
-/*
- * heci_reset - reset host and fw.
- *
- * @dev: Device object for our driver
- * @interrupts: if interrupt should be enable after reset.
- */
-void
-heci_reset(struct iamt_heci_device *dev, int interrupts)
-{
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
- int unexpected = 0;
-
- if (dev->heci_state == HECI_RECOVERING_FROM_RESET) {
- dev->need_reset = 1;
- return;
- }
-
- if (dev->heci_state != HECI_INITIALIZING &&
- dev->heci_state != HECI_DISABLED &&
- dev->heci_state != HECI_POWER_DOWN &&
- dev->heci_state != HECI_POWER_UP)
- unexpected = 1;
-
- if (dev->reinit_tsk != NULL) {
- mutex_exit(&dev->device_lock);
- (void) ddi_taskq_wait(dev->reinit_tsk);
- mutex_enter(&dev->device_lock);
- }
-
- dev->host_hw_state = read_heci_register(dev, H_CSR);
-
- DBG("before reset host_hw_state = 0x%08x.\n",
- dev->host_hw_state);
-
- heci_hw_reset(dev, interrupts);
-
- dev->host_hw_state &= ~H_RST;
- dev->host_hw_state |= H_IG;
-
- write_heci_register(dev, H_CSR, dev->host_hw_state);
-
- DBG("currently saved host_hw_state = 0x%08x.\n",
- dev->host_hw_state);
-
- dev->need_reset = 0;
-
- if (dev->heci_state != HECI_INITIALIZING) {
- if ((dev->heci_state != HECI_DISABLED) &&
- (dev->heci_state != HECI_POWER_DOWN))
- dev->heci_state = HECI_RESETING;
-
- list_for_each_entry_safe(file_pos,
- file_next, &dev->file_list, link,
- struct heci_file_private) {
- file_pos->state = HECI_FILE_DISCONNECTED;
- file_pos->flow_ctrl_creds = 0;
- file_pos->read_cb = NULL;
- file_pos->timer_count = 0;
- }
- /* remove entry if already in list */
- DBG("list del iamthif and wd file list.\n");
- heci_remove_client_from_file_list(dev,
- dev->wd_file_ext.host_client_id);
-
- heci_remove_client_from_file_list(dev,
- dev->iamthif_file_ext.host_client_id);
-
- heci_reset_iamthif_params(dev);
- dev->wd_due_counter = 0;
- dev->extra_write_index = 0;
- }
-
- dev->num_heci_me_clients = 0;
- dev->rd_msg_hdr = 0;
- dev->stop = 0;
- dev->wd_pending = 0;
-
- /* update the state of the registers after reset */
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
-
- DBG("after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- if (unexpected)
- cmn_err(CE_WARN, "unexpected heci reset.\n");
-
- /* Wake up all readings so they can be interrupted */
- list_for_each_entry_safe(file_pos, file_next, &dev->file_list, link,
- struct heci_file_private) {
- cmn_err(CE_NOTE, "heci: Waking up client!\n");
- cv_broadcast(&file_pos->rx_wait);
- }
- /* remove all waiting requests */
- if (dev->write_list.status == 0 &&
- !list_empty(&dev->write_list.heci_cb.cb_list)) {
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->write_list.heci_cb.cb_list, cb_list,
- struct heci_cb_private) {
- if (priv_cb_pos) {
- list_del(&priv_cb_pos->cb_list);
- heci_free_cb_private(priv_cb_pos);
- }
- }
- }
-}
-
-/*
- * heci_initialize_clients - routine.
- *
- * @dev: Device object for our driver
- *
- */
-int
-heci_initialize_clients(struct iamt_heci_device *dev)
-{
- int status;
-
- /* msleep(100) FW needs time to be ready to talk with us */
- delay(drv_usectohz(100000));
- DBG("link is established start sending messages.\n");
- /* link is established start sending messages. */
- status = host_start_message(dev);
- if (status != 0) {
- mutex_enter(&dev->device_lock);
- dev->heci_state = HECI_DISABLED;
- mutex_exit(&dev->device_lock);
- DBG("start sending messages failed.\n");
- return (status);
- }
- /* enumerate clients */
-
- status = host_enum_clients_message(dev);
- if (status != 0) {
- mutex_enter(&dev->device_lock);
- dev->heci_state = HECI_DISABLED;
- mutex_exit(&dev->device_lock);
- DBG("enum clients failed.\n");
- return (status);
- }
- /* allocate storage for ME clients representation */
- status = allocate_me_clients_storage(dev);
- if (status != 0) {
- mutex_enter(&dev->device_lock);
- dev->num_heci_me_clients = 0;
- dev->heci_state = HECI_DISABLED;
- mutex_exit(&dev->device_lock);
- DBG("allocate clients failed.\n");
- return (status);
- }
-
- heci_check_asf_mode(dev);
- /* heci initialization wd */
- host_init_wd(dev);
- /* heci initialization iamthif client */
- host_init_iamthif(dev);
-
- mutex_enter(&dev->device_lock);
- if (dev->need_reset) {
- dev->need_reset = 0;
- dev->heci_state = HECI_DISABLED;
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
-
- (void) memset(dev->heci_host_clients, 0,
- sizeof (dev->heci_host_clients));
- dev->open_handle_count = 0;
- dev->heci_host_clients[0] |= 7;
- dev->current_host_client_id = 3;
- dev->heci_state = HECI_ENABLED;
- mutex_exit(&dev->device_lock);
- DBG("initialization heci clients successful.\n");
- return (0);
-}
-
-/*
- * heci_task_initialize_clients - routine.
- *
- * @data: Device object for our driver
- *
- */
-void
-heci_task_initialize_clients(void *data)
-{
- int ret;
- struct iamt_heci_device *dev = (struct iamt_heci_device *)data;
-
- ret = heci_initialize_clients(dev);
- if (ret)
- cmn_err(CE_WARN, "heci_initialize_clients() failed\n");
-}
-
-/*
- * host_start_message - heci host send start message.
- *
- * @dev: Device object for our driver
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-host_start_message(struct iamt_heci_device *dev)
-{
- long timeout = 60; /* 60 second */
- struct heci_msg_hdr *heci_hdr;
- struct hbm_host_version_request *host_start_req;
- struct hbm_host_stop_request *host_stop_req;
- int err = 0;
- clock_t delta = (clock_t)(timeout * HZ);
-
- /* host start message */
- mutex_enter(&dev->device_lock);
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_host_version_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- host_start_req =
- (struct hbm_host_version_request *)&dev->wr_msg_buf[1];
- (void) memset(host_start_req, 0,
- sizeof (struct hbm_host_version_request));
- host_start_req->cmd.cmd = HOST_START_REQ_CMD;
- host_start_req->host_version.major_version = HBM_MAJOR_VERSION;
- host_start_req->host_version.minor_version = HBM_MINOR_VERSION;
- dev->recvd_msg = 0;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)(host_start_req),
- heci_hdr->length)) {
- DBG("send version to fw fail.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- DBG("call wait_event_interruptible_timeout for response message.\n");
- err = 0;
- while (err != -1 && !dev->recvd_msg) {
- err = cv_reltimedwait(&dev->wait_recvd_msg, &dev->device_lock,
- delta, TR_CLOCK_TICK);
- }
- if (err == -1 && !dev->recvd_msg) {
- DBG("wait_timeout failed on host start response message.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- dev->recvd_msg = 0;
- DBG("wait_timeout successful on host start response message.\n");
- if ((dev->version.major_version != HBM_MAJOR_VERSION) ||
- (dev->version.minor_version != HBM_MINOR_VERSION)) {
- /* send stop message */
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_host_stop_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- host_stop_req =
- (struct hbm_host_stop_request *)&dev->wr_msg_buf[1];
-
- (void) memset(host_stop_req, 0,
- sizeof (struct hbm_host_stop_request));
- host_stop_req->cmd.cmd = HOST_STOP_REQ_CMD;
- host_stop_req->reason = DRIVER_STOP_REQUEST;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)(host_stop_req),
- heci_hdr->length)) {
- DBG("sending stop msg to fw failed.\n");
- }
- DBG("version mismatch.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- mutex_exit(&dev->device_lock);
- return (0);
-}
-
-/*
- * host_enum_clients_message - host send enumeration client request message.
- *
- * @dev: Device object for our driver
- * @return 0 on success, <0 on failure.
- */
-static int
-host_enum_clients_message(struct iamt_heci_device *dev)
-{
- long timeout = 5; /* 5 second */
- struct heci_msg_hdr *heci_hdr;
- struct hbm_host_enum_request *host_enum_req;
- int err = 0;
- uint8_t i, j;
- clock_t delta = (clock_t)(timeout * HZ);
-
- mutex_enter(&dev->device_lock);
-
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- /* enumerate clients */
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_host_enum_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- host_enum_req = (struct hbm_host_enum_request *)&dev->wr_msg_buf[1];
- (void) memset(host_enum_req, 0, sizeof (struct hbm_host_enum_request));
- host_enum_req->cmd.cmd = HOST_ENUM_REQ_CMD;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)(host_enum_req),
- heci_hdr->length)) {
- DBG("send enumeration request failed.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- /* wait for response */
- dev->recvd_msg = 0;
- err = 0;
- while (!dev->recvd_msg && err != -1) {
- err = cv_reltimedwait(&dev->wait_recvd_msg, &dev->device_lock,
- delta, TR_CLOCK_TICK);
- }
- if (err == -1 && !dev->recvd_msg) {
- DBG("wait_event_interruptible_timeout failed "
- "on enumeration clients response message.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- dev->recvd_msg = 0;
-
- /* count how many ME clients we have */
- for (i = 0; i < sizeof (dev->heci_me_clients); i++) {
- for (j = 0; j < 8; j++) {
- if ((dev->heci_me_clients[i] & (1 << j)) != 0)
- dev->num_heci_me_clients++;
-
- }
- }
- mutex_exit(&dev->device_lock);
-
- return (0);
-}
-
-/*
- * host_client_properties - reads properties for client
- *
- * @dev: Device object for our driver
- * @idx: client index in me client array
- * @client_id: id of the client
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-host_client_properties(struct iamt_heci_device *dev,
- struct heci_me_client *client)
-{
- struct heci_msg_hdr *heci_hdr;
- struct hbm_props_request *host_cli_req;
- int err;
- clock_t delta = 10 * HZ;
-
- mutex_enter(&dev->device_lock);
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_props_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- host_cli_req = (struct hbm_props_request *)&dev->wr_msg_buf[1];
- (void) memset(host_cli_req, 0, sizeof (struct hbm_props_request));
- host_cli_req->cmd.cmd = HOST_CLIENT_PROPERTEIS_REQ_CMD;
- host_cli_req->address = client->client_id;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)(host_cli_req), heci_hdr->length)) {
- DBG("send props request failed.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- /* wait for response */
- dev->recvd_msg = 0;
-
- err = 0;
- while (!dev->recvd_msg && err != -1) {
- err = cv_reltimedwait(&dev->wait_recvd_msg, &dev->device_lock,
- delta, TR_CLOCK_TICK);
- }
- if (err == -1 && !dev->recvd_msg) {
- DBG("wait failed on props resp msg.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- dev->recvd_msg = 0;
- mutex_exit(&dev->device_lock);
- return (0);
-}
-
-/*
- * allocate_me_clients_storage - allocate storage for me clients
- *
- * @dev: Device object for our driver
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-allocate_me_clients_storage(struct iamt_heci_device *dev)
-{
- struct heci_me_client *clients;
- struct heci_me_client *client;
- uint8_t num, i, j;
- int err;
-
- if (dev->num_heci_me_clients == 0)
- return (0);
-
- mutex_enter(&dev->device_lock);
- if (dev->me_clients) {
- kmem_free(dev->me_clients, dev->num_heci_me_clients*
- sizeof (struct heci_me_client));
- dev->me_clients = NULL;
- }
- mutex_exit(&dev->device_lock);
-
- /* allocate storage for ME clients representation */
- clients = kmem_zalloc(dev->num_heci_me_clients*
- sizeof (struct heci_me_client), KM_SLEEP);
- if (!clients) {
- DBG("memory allocation for ME clients failed.\n");
- return (-ENOMEM);
- }
-
- mutex_enter(&dev->device_lock);
- dev->me_clients = clients;
- mutex_exit(&dev->device_lock);
-
- num = 0;
- for (i = 0; i < sizeof (dev->heci_me_clients); i++) {
- for (j = 0; j < 8; j++) {
- if ((dev->heci_me_clients[i] & (1 << j)) != 0) {
- client = &dev->me_clients[num];
- client->client_id = (i * 8) + j;
- client->flow_ctrl_creds = 0;
- err = host_client_properties(dev, client);
- if (err != 0) {
- mutex_enter(&dev->device_lock);
- kmem_free(dev->me_clients,
- dev->num_heci_me_clients*
- sizeof (struct heci_me_client));
- dev->me_clients = NULL;
- mutex_exit(&dev->device_lock);
- return (err);
- }
- num++;
- }
- }
- }
-
- return (0);
-}
-
-/*
- * heci_init_file_private - initializes private file structure.
- *
- * @priv: private file structure to be initialized
- * @file: the file structure
- *
- */
-static void
-heci_init_file_private(struct heci_file_private *priv,
- struct heci_file *file)
-{
- _NOTE(ARGUNUSED(file));
-
- (void) memset(priv, 0, sizeof (struct heci_file_private));
- mutex_init(&priv->file_lock, NULL, MUTEX_DRIVER, NULL);
- mutex_init(&priv->read_io_lock, NULL, MUTEX_DRIVER, NULL);
- mutex_init(&priv->write_io_lock, NULL, MUTEX_DRIVER, NULL);
- cv_init(&priv->rx_wait, NULL, CV_DRIVER, NULL);
- DBG("priv->rx_wait =%p\n", (void *)&priv->rx_wait);
- LIST_INIT_HEAD(&priv->link);
- priv->reading_state = HECI_IDLE;
- priv->writing_state = HECI_IDLE;
-}
-
-/*
- * heci_find_me_client - search for ME client guid
- * sets client_id in heci_file_private if found
- * @dev: Device object for our driver
- * @priv: private file structure to set client_id in
- * @cguid: searched guid of ME client
- * @client_id: id of host client to be set in file private structure
- *
- * @return ME client index
- */
-static uint8_t
-heci_find_me_client(struct iamt_heci_device *dev,
- struct heci_file_private *priv,
- const struct guid *cguid, uint8_t client_id)
-{
- uint8_t i;
-
- if ((dev == NULL) || (priv == NULL) || (cguid == NULL))
- return (0);
-
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (memcmp(cguid,
- &dev->me_clients[i].props.protocol_name,
- sizeof (struct guid)) == 0) {
- priv->me_client_id = dev->me_clients[i].client_id;
- priv->state = HECI_FILE_CONNECTING;
- priv->host_client_id = client_id;
-
- list_add_tail(&priv->link, &dev->file_list);
- return (i);
- }
- }
- return (0);
-}
-
-/*
- * heci_check_asf_mode - check for ASF client
- *
- * @dev: Device object for our driver
- *
- */
-static void
-heci_check_asf_mode(struct iamt_heci_device *dev)
-{
- uint8_t i;
-
- mutex_enter(&dev->device_lock);
- dev->asf_mode = 0;
- /* find ME ASF client - otherwise assume AMT mode */
- DBG("find ME ASF client - otherwise assume AMT mode.\n");
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (memcmp(&heci_asf_guid,
- &dev->me_clients[i].props.protocol_name,
- sizeof (struct guid)) == 0) {
- dev->asf_mode = 1;
- mutex_exit(&dev->device_lock);
- DBG("found ME ASF client.\n");
- return;
- }
- }
- mutex_exit(&dev->device_lock);
- DBG("assume AMT mode.\n");
-}
-
-/*
- * heci_connect_me_client - connect ME client
- * @dev: Device object for our driver
- * @priv: private file structure
- * @timeout: connect timeout in seconds
- *
- * @return 1 - if connected, 0 - if not
- */
-static uint8_t
-heci_connect_me_client(struct iamt_heci_device *dev,
- struct heci_file_private *priv,
- long timeout)
-{
- int err = 0;
- clock_t delta = (clock_t)(timeout * HZ);
-
- if ((dev == NULL) || (priv == NULL))
- return (0);
-
- if (!heci_connect(dev, priv)) {
- DBG("failed to call heci_connect for client_id=%d.\n",
- priv->host_client_id);
- heci_remove_client_from_file_list(dev, priv->host_client_id);
- priv->state = HECI_FILE_DISCONNECTED;
- return (0);
- }
- err = 0;
- while (!(HECI_FILE_CONNECTED == priv->state ||
- HECI_FILE_DISCONNECTED == priv->state) &&
- err != -1) {
- err = cv_reltimedwait(&dev->wait_recvd_msg, &dev->device_lock,
- delta, TR_CLOCK_TICK);
- }
- if (HECI_FILE_CONNECTED != priv->state) {
- heci_remove_client_from_file_list(dev, priv->host_client_id);
- DBG("failed to connect client_id=%d state=%d.\n",
- priv->host_client_id, priv->state);
- if (err)
- DBG("failed connect err=%08x\n", err);
- priv->state = HECI_FILE_DISCONNECTED;
- return (0);
- }
- DBG("successfully connected client_id=%d.\n",
- priv->host_client_id);
- return (1);
-}
-
-/*
- * host_init_wd - heci initialization wd.
- *
- * @dev: Device object for our driver
- *
- */
-static void host_init_wd(struct iamt_heci_device *dev)
-{
-
- mutex_enter(&dev->device_lock);
-
- heci_init_file_private(&dev->wd_file_ext, NULL);
-
- /* look for WD client and connect to it */
- dev->wd_file_ext.state = HECI_FILE_DISCONNECTED;
- dev->wd_timeout = 0;
-
- if (dev->asf_mode) {
- (void) memcpy(dev->wd_data, stop_wd_params,
- HECI_WD_PARAMS_SIZE);
- } else {
- /* AMT mode */
- dev->wd_timeout = AMT_WD_VALUE;
- DBG("dev->wd_timeout=%d.\n", dev->wd_timeout);
- (void) memcpy(dev->wd_data, start_wd_params,
- HECI_WD_PARAMS_SIZE);
- (void) memcpy(dev->wd_data + HECI_WD_PARAMS_SIZE,
- &dev->wd_timeout, sizeof (uint16_t));
- }
-
- /* find ME WD client */
- (void) heci_find_me_client(dev, &dev->wd_file_ext,
- &heci_wd_guid, HECI_WD_HOST_CLIENT_ID);
-
- DBG("check wd_file_ext\n");
- if (HECI_FILE_CONNECTING == dev->wd_file_ext.state) {
- if (heci_connect_me_client(dev, &dev->wd_file_ext, 15) == 1) {
- DBG("dev->wd_timeout=%d.\n", dev->wd_timeout);
- if (dev->wd_timeout != 0)
- dev->wd_due_counter = 1;
- else
- dev->wd_due_counter = 0;
- DBG("successfully connected to WD client.\n");
- }
- } else
- DBG("failed to find WD client.\n");
-
-
- mutex_exit(&dev->device_lock);
-}
-
-
-/*
- * host_init_iamthif - heci initialization iamthif client.
- *
- * @dev: Device object for our driver
- *
- */
-static void
-host_init_iamthif(struct iamt_heci_device *dev)
-{
- uint8_t i;
-
- mutex_enter(&dev->device_lock);
-
- heci_init_file_private(&dev->iamthif_file_ext, NULL);
- dev->iamthif_file_ext.state = HECI_FILE_DISCONNECTED;
-
- /* find ME PTHI client */
- i = heci_find_me_client(dev, &dev->iamthif_file_ext,
- &heci_pthi_guid, HECI_IAMTHIF_HOST_CLIENT_ID);
- if (dev->iamthif_file_ext.state != HECI_FILE_CONNECTING) {
- DBG("failed to find iamthif client.\n");
- mutex_exit(&dev->device_lock);
- return;
- }
-
- ASSERT(dev->me_clients[i].props.max_msg_length == IAMTHIF_MTU);
-
- if (heci_connect_me_client(dev, &dev->iamthif_file_ext, 15) == 1) {
- DBG("connected to iamthif client.\n");
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
- }
- mutex_exit(&dev->device_lock);
-}
-
-/*
- * heci_alloc_file_private - allocates a private file structure and set it up.
- * @file: the file structure
- *
- * @return The allocated file or NULL on failure
- */
-struct heci_file_private *
-heci_alloc_file_private(struct heci_file *file)
-{
- struct heci_file_private *priv;
-
- priv = kmem_zalloc(sizeof (struct heci_file_private), KM_SLEEP);
- if (!priv)
- return (NULL);
-
- heci_init_file_private(priv, file);
-
- return (priv);
-}
-
-/*
- * heci_free_file_private - free a private file structure that were previously
- * allocated by heci_alloc_file_private
- */
-void
-heci_free_file_private(struct heci_file_private *priv)
-{
- mutex_destroy(&priv->file_lock);
- mutex_destroy(&priv->read_io_lock);
- mutex_destroy(&priv->write_io_lock);
- cv_destroy(&priv->rx_wait);
- kmem_free(priv, sizeof (struct heci_file_private));
-
-}
-
-/*
- * heci_disconnect_host_client - send disconnect message to fw from host
- * client.
- *
- * @dev: Device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_disconnect_host_client(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- int rets, err;
- long timeout = 15; /* 15 seconds */
- struct heci_cb_private *priv_cb;
- clock_t delta = (clock_t)(timeout * HZ);
-
- if ((!dev) || (!file_ext))
- return (-ENODEV);
-
- if (file_ext->state != HECI_FILE_DISCONNECTING)
- return (0);
-
- priv_cb = kmem_zalloc(sizeof (struct heci_cb_private), KM_SLEEP);
- if (!priv_cb)
- return (-ENOMEM);
-
- LIST_INIT_HEAD(&priv_cb->cb_list);
- priv_cb->file_private = file_ext;
- priv_cb->major_file_operations = HECI_CLOSE;
- mutex_enter(&dev->device_lock);
- if (dev->host_buffer_is_empty) {
- dev->host_buffer_is_empty = 0;
- if (heci_disconnect(dev, file_ext)) {
- list_add_tail(&priv_cb->cb_list,
- &dev->ctrl_rd_list.heci_cb.cb_list);
- } else {
- mutex_exit(&dev->device_lock);
- rets = -ENODEV;
- DBG("failed to call heci_disconnect.\n");
- goto free;
- }
- } else {
- DBG("add disconnect cb to control write list\n");
- list_add_tail(&priv_cb->cb_list,
- &dev->ctrl_wr_list.heci_cb.cb_list);
- }
-
- err = 0;
- while (err != -1 &&
- (HECI_FILE_DISCONNECTED != file_ext->state)) {
-
- err = cv_reltimedwait(&dev->wait_recvd_msg, &dev->device_lock,
- delta, TR_CLOCK_TICK);
- }
- mutex_exit(&dev->device_lock);
-
- if (HECI_FILE_DISCONNECTED == file_ext->state) {
- rets = 0;
- DBG("successfully disconnected from fw client."
- " me_client_id:%d, host_client_id:%d\n",
- file_ext->me_client_id,
- file_ext->host_client_id);
- } else {
- rets = -ENODEV;
- if (HECI_FILE_DISCONNECTED != file_ext->state)
- DBG("wrong status client disconnect.\n");
-
- if (err)
- DBG("wait failed disconnect err=%08x\n", err);
-
- DBG("failed to disconnect from fw client.\n"
- " me_client_id:%d, host_client_id:%d\n",
- file_ext->me_client_id,
- file_ext->host_client_id);
- }
-
- mutex_enter(&dev->device_lock);
- heci_flush_list(&dev->ctrl_rd_list, file_ext);
- heci_flush_list(&dev->ctrl_wr_list, file_ext);
- mutex_exit(&dev->device_lock);
-free:
- heci_free_cb_private(priv_cb);
- return (rets);
-}
-
-/*
- * heci_remove_client_from_file_list -
- * remove file private data from device file list
- *
- * @dev: Device object for our driver
- * @host_client_id: host client id to be removed
- *
- */
-void
-heci_remove_client_from_file_list(struct iamt_heci_device *dev,
- uint8_t host_client_id)
-{
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
- list_for_each_entry_safe(file_pos, file_next, &dev->file_list, link,
- struct heci_file_private) {
- if (host_client_id == file_pos->host_client_id) {
- DBG("remove host client = %d, ME client = %d\n",
- file_pos->host_client_id,
- file_pos->me_client_id);
- list_del_init(&file_pos->link);
- break;
- }
- }
-}
-
-/*
- * heci_fe_same_id - tell if file private data have same id
- *
- * @fe1: private data of 1. file object
- * @fe2: private data of 2. file object
- *
- * @return !=0 - if ids are the same, 0 - if differ.
- */
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2)
-{
- return ((fe1->host_client_id == fe2->host_client_id) &&
- (fe1->me_client_id == fe2->me_client_id));
-}
diff --git a/usr/src/uts/intel/io/heci/heci_interface.c b/usr/src/uts/intel/io/heci/heci_interface.c
deleted file mode 100644
index 00b74cc75d..0000000000
--- a/usr/src/uts/intel/io/heci/heci_interface.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/ddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/devops.h>
-#include <sys/instance.h>
-#include <sys/modctl.h>
-#include <sys/open.h>
-#include <sys/stat.h>
-#include <sys/sunddi.h>
-#include <sys/sunndi.h>
-#include <sys/systm.h>
-#include <sys/mkdev.h>
-#include <sys/list.h>
-#include "heci_data_structures.h"
-#include "heci.h"
-#include "heci_interface.h"
-
-
-
-static const uint8_t interface_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10};
-static const uint8_t interface_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10};
-
-/*
- * read_heci_register - Read a byte from the heci device
- *
- * @device: the device structure
- * @offset: offset from which to read the data
- *
- * @return the byte read.
- */
-uint32_t
-read_heci_register(struct iamt_heci_device *device,
- unsigned long offset)
-{
- return (ddi_get32(device->io_handle,
- (uint32_t *)(long)(device->mem_addr + offset)));
-}
-
-/*
- * write_heci_register - Write 4 bytes to the heci device
- *
- * @device: the device structure
- * @offset: offset from which to write the data
- * @value: the byte to write
- */
-void
-write_heci_register(struct iamt_heci_device *device, unsigned long offset,
- uint32_t value)
-{
- ddi_put32(device->io_handle,
- (uint32_t *)(long)(device->mem_addr + offset), value);
-}
-
-
-/*
- * heci_set_csr_register - write H_CSR register to the heci device
- *
- * @dev: device object for our driver
- */
-void
-heci_set_csr_register(struct iamt_heci_device *dev)
-{
- write_heci_register(dev, H_CSR, dev->host_hw_state);
- dev->host_hw_state = read_heci_register(dev, H_CSR);
-}
-
-/*
- * heci_csr_enable_interrupts - enable heci device interrupts
- *
- * @dev: device object for our driver
- */
-void
-heci_csr_enable_interrupts(struct iamt_heci_device *dev)
-{
- dev->host_hw_state |= H_IE;
- heci_set_csr_register(dev);
-}
-
-/*
- * heci_csr_disable_interrupts - disable heci device interrupts
- *
- * @dev: device object for our driver
- */
-void
-heci_csr_disable_interrupts(struct iamt_heci_device *dev)
-{
- dev->host_hw_state &= ~H_IE;
- heci_set_csr_register(dev);
-}
-
-
-/*
- * _host_get_filled_slots - get number of device filled buffer slots
- *
- * @device: the device structure
- *
- * @return numer of filled slots
- */
-static unsigned char
-_host_get_filled_slots(struct iamt_heci_device *dev)
-{
- char read_ptr, write_ptr;
-
- read_ptr = (char)((dev->host_hw_state & H_CBRP) >> 8);
- write_ptr = (char)((dev->host_hw_state & H_CBWP) >> 16);
-
- return ((unsigned char)(write_ptr - read_ptr));
-}
-
-/*
- * host_buffer_is_empty - check if host buffer is empty.
- *
- * @dev: device object for our driver
- *
- * @return 1 if empty, 0 - otherwise.
- */
-int
-host_buffer_is_empty(struct iamt_heci_device *dev)
-{
- unsigned char filled_slots;
-
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- filled_slots = _host_get_filled_slots(dev);
-
- if (filled_slots > 0)
- return (0);
-
- return (1);
-}
-
-/*
- * count_empty_write_slots - count write empty slots.
- *
- * @dev: device object for our driver
- *
- * @return -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
- */
-int32_t
-count_empty_write_slots(struct iamt_heci_device *dev)
-{
- unsigned char buffer_depth, filled_slots, empty_slots;
-
- buffer_depth = (unsigned char)((dev->host_hw_state & H_CBD) >> 24);
- filled_slots = _host_get_filled_slots(dev);
- empty_slots = buffer_depth - filled_slots;
-
- if (filled_slots > buffer_depth) {
- /* overflow */
- return (-ESLOTS_OVERFLOW);
- }
-
- return ((int32_t)empty_slots);
-}
-
-/*
- * heci_write_message - write a message to heci device.
- *
- * @dev: device object for our driver
- * @heci_hdr: header of message
- * @write_buffer: message buffer will be write
- * @write_length: message size will be write
- *
- * @return 1 if success, 0 - otherwise.
- */
-int
-heci_write_message(struct iamt_heci_device *dev,
- struct heci_msg_hdr *header,
- unsigned char *write_buffer,
- unsigned long write_length)
-{
- uint32_t temp_msg = 0;
- unsigned long bytes_written = 0;
- unsigned char buffer_depth, filled_slots, empty_slots;
- unsigned long dw_to_write;
-
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- DBG("host_hw_state = 0x%08x.\n", dev->host_hw_state);
- DBG("heci_write_message header=%08x.\n", *((uint32_t *)(void *)header));
- buffer_depth = (unsigned char)((dev->host_hw_state & H_CBD) >> 24);
- filled_slots = _host_get_filled_slots(dev);
- empty_slots = buffer_depth - filled_slots;
- DBG("filled = %u, empty = %u.\n", filled_slots, empty_slots);
-
- dw_to_write = ((write_length + 3) / 4);
-
- if (dw_to_write > empty_slots)
- return (0);
-
- write_heci_register(dev, H_CB_WW, *((uint32_t *)(void *)header));
-
- while (write_length >= 4) {
- write_heci_register(dev, H_CB_WW,
- *(uint32_t *)(void *)(write_buffer + bytes_written));
- bytes_written += 4;
- write_length -= 4;
- }
-
- if (write_length > 0) {
- (void) memcpy(&temp_msg, &write_buffer[bytes_written],
- write_length);
- write_heci_register(dev, H_CB_WW, temp_msg);
- }
-
- dev->host_hw_state |= H_IG;
- write_heci_register(dev, H_CSR, dev->host_hw_state);
- dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
- if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
- return (0);
-
- dev->write_hang = 0;
- return (1);
-}
-
-/*
- * count_full_read_slots - count read full slots.
- *
- * @dev: device object for our driver
- *
- * @return -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count
- */
-int32_t
-count_full_read_slots(struct iamt_heci_device *dev)
-{
- char read_ptr, write_ptr;
- unsigned char buffer_depth, filled_slots;
-
- dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
- buffer_depth = (unsigned char)((dev->me_hw_state & ME_CBD_HRA) >> 24);
- read_ptr = (char)((dev->me_hw_state & ME_CBRP_HRA) >> 8);
- write_ptr = (char)((dev->me_hw_state & ME_CBWP_HRA) >> 16);
- filled_slots = (unsigned char)(write_ptr - read_ptr);
-
- if (filled_slots > buffer_depth) {
- /* overflow */
- return (-ESLOTS_OVERFLOW);
- }
-
- DBG("filled_slots =%08x \n", filled_slots);
- return ((int32_t)filled_slots);
-}
-
-/*
- * heci_read_slots - read a message from heci device.
- *
- * @dev: device object for our driver
- * @buffer: message buffer will be write
- * @buffer_length: message size will be read
- */
-void
-heci_read_slots(struct iamt_heci_device *dev,
- unsigned char *buffer, unsigned long buffer_length)
-{
- uint32_t i = 0;
- unsigned char temp_buf[sizeof (uint32_t)];
-
- while (buffer_length >= sizeof (uint32_t)) {
- ((uint32_t *)(void *)buffer)[i] =
- read_heci_register(dev, ME_CB_RW);
- DBG("buffer[%d]= %d\n", i, ((uint32_t *)(void *)buffer)[i]);
- i++;
- buffer_length -= sizeof (uint32_t);
- }
-
- if (buffer_length > 0) {
- *((uint32_t *)(void *)&temp_buf) =
- read_heci_register(dev, ME_CB_RW);
- (void) memcpy(&buffer[i * 4], temp_buf, buffer_length);
- }
-
- dev->host_hw_state |= H_IG;
- heci_set_csr_register(dev);
-}
-
-/*
- * flow_ctrl_creds - check flow_control credentials.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 1 if flow_ctrl_creds >0, 0 - otherwise.
- */
-int
-flow_ctrl_creds(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- uint8_t i;
-
- if (!dev->num_heci_me_clients)
- return (0);
-
- if (file_ext == NULL)
- return (0);
-
- if (file_ext->flow_ctrl_creds > 0)
- return (1);
-
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id == file_ext->me_client_id) {
- if (dev->me_clients[i].flow_ctrl_creds > 0) {
- ASSERT(dev->me_clients[i].props.single_recv_buf
- != 0);
- return (1);
- }
- return (0);
- }
- }
- ASSERT(0);
- return (0);
-}
-
-/*
- * flow_ctrl_reduce - reduce flow_control.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- */
-void
-flow_ctrl_reduce(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- uint8_t i;
-
- if (!dev->num_heci_me_clients)
- return;
-
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id == file_ext->me_client_id) {
- if (dev->me_clients[i].props.single_recv_buf != 0) {
- ASSERT(dev->me_clients[i].flow_ctrl_creds > 0);
- dev->me_clients[i].flow_ctrl_creds--;
- } else {
- ASSERT(file_ext->flow_ctrl_creds > 0);
- file_ext->flow_ctrl_creds--;
- }
- return;
- }
- }
- ASSERT(0);
-}
-
-/*
- * heci_send_flow_control - send flow control to fw.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 1 if success, 0 - otherwise.
- */
-int
-heci_send_flow_control(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- struct heci_msg_hdr *heci_hdr;
- struct hbm_flow_control *heci_flow_control;
-
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_flow_control);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- heci_flow_control = (struct hbm_flow_control *)&dev->wr_msg_buf[1];
- (void) memset(heci_flow_control, 0, sizeof (heci_flow_control));
- heci_flow_control->host_addr = file_ext->host_client_id;
- heci_flow_control->me_addr = file_ext->me_client_id;
- heci_flow_control->cmd.cmd = HECI_FLOW_CONTROL_CMD;
- (void) memset(heci_flow_control->reserved, 0,
- sizeof (heci_flow_control->reserved));
- DBG("sending flow control host client = %d, me client = %d\n",
- file_ext->host_client_id, file_ext->me_client_id);
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)heci_flow_control,
- sizeof (struct hbm_flow_control)))
- return (0);
-
- return (1);
-
-}
-
-/*
- * other_client_is_connecting - check if other
- * client with the same client id is connected.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 1 if other client is connected, 0 - otherwise.
- */
-int
-other_client_is_connecting(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
-
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
- list_for_each_entry_safe(file_pos, file_next, &dev->file_list, link,
- struct heci_file_private) {
- if ((file_pos->state == HECI_FILE_CONNECTING) &&
- (file_pos != file_ext) &&
- file_ext->me_client_id == file_pos->me_client_id)
- return (1);
-
- }
- return (0);
-}
-
-/*
- * heci_send_wd - send watch dog message to fw.
- *
- * @dev: device object for our driver
- *
- * @return 1 if success, 0 - otherwise.
- */
-int
-heci_send_wd(struct iamt_heci_device *dev)
-{
- struct heci_msg_hdr *heci_hdr;
-
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = dev->wd_file_ext.host_client_id;
- heci_hdr->me_addr = dev->wd_file_ext.me_client_id;
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- if (!memcmp(dev->wd_data, interface_start_wd_params,
- HECI_WD_PARAMS_SIZE)) {
- heci_hdr->length = HECI_START_WD_DATA_SIZE;
- } else {
- ASSERT(!memcmp(dev->wd_data, interface_stop_wd_params,
- HECI_WD_PARAMS_SIZE));
- heci_hdr->length = HECI_WD_PARAMS_SIZE;
- }
-
- if (!heci_write_message(dev, heci_hdr, dev->wd_data, heci_hdr->length))
- return (0);
-
- return (1);
-}
-
-/*
- * heci_disconnect - send disconnect message to fw.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 1 if success, 0 - otherwise.
- */
-int
-heci_disconnect(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- struct heci_msg_hdr *heci_hdr;
- struct hbm_client_disconnect_request *heci_cli_disconnect;
-
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_client_disconnect_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- heci_cli_disconnect =
- (struct hbm_client_disconnect_request *)&dev->wr_msg_buf[1];
- (void) memset(heci_cli_disconnect, 0, sizeof (heci_cli_disconnect));
- heci_cli_disconnect->host_addr = file_ext->host_client_id;
- heci_cli_disconnect->me_addr = file_ext->me_client_id;
- heci_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD;
- heci_cli_disconnect->reserved[0] = 0;
-
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)heci_cli_disconnect,
- sizeof (struct hbm_client_disconnect_request)))
- return (0);
-
- return (1);
-}
-
-/*
- * heci_connect - send connect message to fw.
- *
- * @dev: device object for our driver
- * @file_ext: private data of the file object
- *
- * @return 1 if success, 0 - otherwise.
- */
-int
-heci_connect(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- struct heci_msg_hdr *heci_hdr;
- struct hbm_client_connect_request *heci_cli_connect;
-
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_client_connect_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- heci_cli_connect =
- (struct hbm_client_connect_request *)&dev->wr_msg_buf[1];
- heci_cli_connect->host_addr = file_ext->host_client_id;
- heci_cli_connect->me_addr = file_ext->me_client_id;
- heci_cli_connect->cmd.cmd = CLIENT_CONNECT_REQ_CMD;
- heci_cli_connect->reserved = 0;
-
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)heci_cli_connect,
- sizeof (struct hbm_client_connect_request)))
- return (0);
-
- return (1);
-}
diff --git a/usr/src/uts/intel/io/heci/heci_interface.h b/usr/src/uts/intel/io/heci/heci_interface.h
deleted file mode 100644
index 254f8a896d..0000000000
--- a/usr/src/uts/intel/io/heci/heci_interface.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-
-#ifndef _HECI_INTERFACE_H_
-#define _HECI_INTERFACE_H_
-
-
-#define HBM_MINOR_VERSION 0
-#define HBM_MAJOR_VERSION 1
-#define HBM_TIMEOUT 1 /* 1 second */
-
-
-#define HOST_START_REQ_CMD 0x01
-#define HOST_START_RES_CMD 0x81
-
-#define HOST_STOP_REQ_CMD 0x02
-#define HOST_STOP_RES_CMD 0x82
-
-#define ME_STOP_REQ_CMD 0x03
-
-#define HOST_ENUM_REQ_CMD 0x04
-#define HOST_ENUM_RES_CMD 0x84
-
-#define HOST_CLIENT_PROPERTEIS_REQ_CMD 0x05
-#define HOST_CLIENT_PROPERTEIS_RES_CMD 0x85
-
-#define CLIENT_CONNECT_REQ_CMD 0x06
-#define CLIENT_CONNECT_RES_CMD 0x86
-
-#define CLIENT_DISCONNECT_REQ_CMD 0x07
-#define CLIENT_DISCONNECT_RES_CMD 0x87
-
-#define HECI_FLOW_CONTROL_CMD 0x08
-
-
-#define AMT_WD_VALUE 120 /* seconds */
-
-#define HECI_WATCHDOG_DATA_SIZE 16
-#define HECI_START_WD_DATA_SIZE 20
-#define HECI_WD_PARAMS_SIZE 4
-
-#pragma pack(1)
-/* IOCTL commands */
-#define IOCTL_HECI_GET_VERSION \
- _IOWR('H', 0x0, struct heci_message_data)
-#define IOCTL_HECI_CONNECT_CLIENT \
- _IOWR('H', 0x01, struct heci_message_data)
-#define IOCTL_HECI_WD \
- _IOWR('H', 0x02, struct heci_message_data)
-#define IOCTL_HECI_BYPASS_WD \
- _IOWR('H', 0x10, struct heci_message_data)
-
-
-enum heci_stop_reason_types {
- DRIVER_STOP_REQUEST = 0x00,
- DEVICE_D1_ENTRY = 0x01,
- DEVICE_D2_ENTRY = 0x02,
- DEVICE_D3_ENTRY = 0x03,
- SYSTEM_S1_ENTRY = 0x04,
- SYSTEM_S2_ENTRY = 0x05,
- SYSTEM_S3_ENTRY = 0x06,
- SYSTEM_S4_ENTRY = 0x07,
- SYSTEM_S5_ENTRY = 0x08
-};
-
-enum me_stop_reason_types {
- FW_UPDATE = 0x00
-};
-
-enum client_connect_status_types {
- CCS_SUCCESS = 0x00,
- CCS_NOT_FOUND = 0x01,
- CCS_ALREADY_STARTED = 0x02,
- CCS_OUT_OF_RESOURCES = 0x03,
- CCS_MESSAGE_SMALL = 0x04
-};
-
-enum client_disconnect_status_types {
- CDS_SUCCESS = 0x00
-};
-
-
-/*
- * heci interface function prototypes
- */
-void heci_set_csr_register(struct iamt_heci_device *dev);
-void heci_csr_enable_interrupts(struct iamt_heci_device *dev);
-void heci_csr_disable_interrupts(struct iamt_heci_device *dev);
-
-void heci_read_slots(struct iamt_heci_device *dev,
- unsigned char *buffer, unsigned long buffer_length);
-
-int heci_write_message(struct iamt_heci_device *dev,
- struct heci_msg_hdr *header,
- unsigned char *write_buffer,
- unsigned long write_length);
-
-int host_buffer_is_empty(struct iamt_heci_device *dev);
-
-int32_t count_full_read_slots(struct iamt_heci_device *dev);
-
-int32_t count_empty_write_slots(struct iamt_heci_device *dev);
-
-int flow_ctrl_creds(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-
-int heci_send_wd(struct iamt_heci_device *dev);
-
-void flow_ctrl_reduce(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-
-int heci_send_flow_control(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-
-int heci_disconnect(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-int other_client_is_connecting(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-int heci_connect(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-
-#endif /* _HECI_INTERFACE_H_ */
diff --git a/usr/src/uts/intel/io/heci/heci_intr.c b/usr/src/uts/intel/io/heci/heci_intr.c
deleted file mode 100644
index 56c75308fc..0000000000
--- a/usr/src/uts/intel/io/heci/heci_intr.c
+++ /dev/null
@@ -1,1638 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/ddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/devops.h>
-#include <sys/instance.h>
-#include <sys/modctl.h>
-#include <sys/open.h>
-#include <sys/stat.h>
-#include <sys/sunddi.h>
-#include <sys/sunndi.h>
-#include <sys/systm.h>
-#include <sys/mkdev.h>
-#include <sys/list.h>
-#include <sys/note.h>
-#include "heci_data_structures.h"
-
-#include "heci.h"
-#include "heci_interface.h"
-
-/*
- * interrupt function prototypes
- */
-static void heci_bh_handler(void *data);
-static int heci_bh_read_handler(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- int32_t *slots);
-static int heci_bh_write_handler(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- int32_t *slots);
-static void heci_bh_read_bus_message(struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr);
-static int heci_bh_read_pthi_message(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr);
-static int heci_bh_read_client_message(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr);
-static void heci_client_connect_response(struct iamt_heci_device *dev,
- struct hbm_client_connect_response *connect_res);
-static void heci_client_disconnect_response(struct iamt_heci_device *dev,
- struct hbm_client_connect_response *disconnect_res);
-static void heci_client_flow_control_response(struct iamt_heci_device *dev,
- struct hbm_flow_control *flow_control);
-static void heci_client_disconnect_request(struct iamt_heci_device *dev,
- struct hbm_client_disconnect_request *disconnect_req);
-
-static int heci_bh_process_device(struct iamt_heci_device *dev);
-
-/*
- * heci_isr_interrupt - The ISR of the HECI device
- *
- * @irq: The irq number
- * @dev_id: pointer to the device structure
- *
- * @return irqreturn_t
- */
-uint_t
-heci_isr_interrupt(caddr_t arg1)
-{
- struct iamt_heci_device *device =
- (struct iamt_heci_device *)(void *)arg1;
-
- mutex_enter(&device->device_lock);
-
- if (device->heci_state == HECI_POWER_DOWN) {
- mutex_exit(&device->device_lock);
- return (DDI_INTR_UNCLAIMED);
- }
- device->host_hw_state = read_heci_register(device, H_CSR);
-
- if ((device->host_hw_state & H_IS) != H_IS) {
- mutex_exit(&device->device_lock);
- return (DDI_INTR_UNCLAIMED);
- }
-
- /* disable interrupts */
- heci_csr_disable_interrupts(device);
-
- mutex_exit(&device->device_lock);
-
- /*
- * Our device interrupted, schedule work the heci_bh_handler
- * to handle the interrupt processing. This needs to be a
- * taskq
- */
- DBG("schedule work the heci_bh_handler.\n");
- if (ddi_taskq_dispatch(device->work, heci_bh_handler,
- (void*)arg1, DDI_NOSLEEP) == DDI_FAILURE)
- cmn_err(CE_WARN, "taskq_dispatch failed for heci_bh_handler");
-
- return (DDI_INTR_CLAIMED);
-}
-
-/*
- * _heci_cmpl: process completed operation.
- *
- * @file_ext: private data of the file object.
- * @priv_cb_pos: callback block.
- */
-static void _heci_cmpl(struct heci_file_private *file_ext,
- struct heci_cb_private *priv_cb_pos)
-{
- if (priv_cb_pos->major_file_operations == HECI_WRITE) {
- heci_free_cb_private(priv_cb_pos);
- DBG("completing write call back.\n");
- file_ext->writing_state = HECI_WRITE_COMPLETE;
- pollwakeup(&file_ext->tx_pollwait, POLL_IN|POLLRDNORM);
-
- } else if (priv_cb_pos->major_file_operations == HECI_READ &&
- HECI_READING == file_ext->reading_state) {
- DBG("completing read call back information= %lu\n",
- priv_cb_pos->information);
- file_ext->reading_state = HECI_READ_COMPLETE;
- cv_broadcast(&file_ext->rx_wait);
-
- }
-}
-
-/*
- * _heci_cmpl_iamthif: process completed iamthif operation.
- *
- * @dev: Device object for our driver.
- * @priv_cb_pos: callback block.
- */
-static void _heci_cmpl_iamthif(struct iamt_heci_device *dev,
- struct heci_cb_private *priv_cb_pos)
-{
- if (dev->iamthif_canceled != 1) {
- dev->iamthif_state = HECI_IAMTHIF_READ_COMPLETE;
- dev->iamthif_stall_timer = 0;
- (void) memcpy(priv_cb_pos->response_buffer.data,
- dev->iamthif_msg_buf,
- dev->iamthif_msg_buf_index);
- list_add_tail(&priv_cb_pos->cb_list,
- &dev->pthi_read_complete_list.heci_cb.cb_list);
- DBG("pthi read completed.\n");
- } else {
- run_next_iamthif_cmd(dev);
- }
- if (&dev->iamthif_file_ext.pollwait) {
- DBG("completing pthi call back.\n");
- pollwakeup(&dev->iamthif_file_ext.pollwait, POLL_IN|POLLRDNORM);
- }
-}
-/*
- * heci_bh_handler - function called after ISR to handle the interrupt
- * processing.
- *
- * @work: pointer to the work structure
- *
- * NOTE: This function is called by schedule work
- */
-static void
-heci_bh_handler(void *data)
-{
- struct iamt_heci_device *dev = (struct iamt_heci_device *)data;
-
-#ifdef SUNOS
- while (heci_bh_process_device(dev))
- ;
-#elif defined(LINUX)
- if (heci_bh_process_device(dev)) {
- PEPARE_WORK(&dev->work, heci_bh_handler);
- DBG("schedule work the heci_bh_handler.\n");
- rets = schedule_work(&dev->work);
- if (!rets) {
- printk(KERN_ERR "heci: schedule the heci_bh_handler"
- " failed error=%x\n", rets);
- }
- }
-#else
-
-#error "Unknown platform!"
-
-#endif
-}
-
-static int
-heci_bh_process_device(struct iamt_heci_device *dev)
-{
- struct io_heci_list complete_list;
- int32_t slots;
- int rets, isr_pending = 0;
- struct heci_cb_private *cb_pos = NULL, *cb_next = NULL;
- struct heci_file_private *file_ext;
- int bus_message_received = 0;
-
- DBG("function called after ISR to handle the interrupt processing.\n");
- /* initialize our complete list */
- mutex_enter(&dev->device_lock);
- heci_initialize_list(&complete_list, dev);
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- dev->me_hw_state = read_heci_register(dev, ME_CSR_HA);
-
- /* check if ME wants a reset */
- if (((dev->me_hw_state & ME_RDY_HRA) == 0) &&
- (dev->heci_state != HECI_RESETING) &&
- (dev->heci_state != HECI_INITIALIZING)) {
- DBG("FW not ready.\n");
- heci_reset(dev, 1);
- mutex_exit(&dev->device_lock);
- return (0);
- }
-
- /* check if we need to start the dev */
- if ((dev->host_hw_state & H_RDY) == 0) {
- if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
- DBG("we need to start the dev.\n");
- dev->host_hw_state |= (H_IE | H_IG | H_RDY);
- heci_set_csr_register(dev);
- if (dev->heci_state == HECI_INITIALIZING) {
- dev->recvd_msg = 1;
- cv_broadcast(&dev->wait_recvd_msg);
- mutex_exit(&dev->device_lock);
-
- return (0);
-
- } else {
- mutex_exit(&dev->device_lock);
- if (dev->reinit_tsk &&
- ddi_taskq_dispatch(dev->reinit_tsk,
- heci_task_initialize_clients,
- dev, DDI_SLEEP) == DDI_FAILURE) {
-
- cmn_err(CE_WARN, "taskq_dispatch "
- "failed for reinit_tsk");
- }
- return (0);
- }
- } else {
- DBG("enable interrupt FW not ready.\n");
- heci_csr_enable_interrupts(dev);
- mutex_exit(&dev->device_lock);
- return (0);
- }
- }
- /* check slots avalable for reading */
- slots = count_full_read_slots(dev);
- DBG("slots =%08x extra_write_index =%08x.\n",
- slots, dev->extra_write_index);
- while ((slots > 0) && (!dev->extra_write_index)) {
- DBG("slots =%08x extra_write_index =%08x.\n", slots,
- dev->extra_write_index);
- DBG("call heci_bh_read_handler.\n");
- rets = heci_bh_read_handler(&complete_list, dev, &slots);
- if (rets != 0)
- goto end;
- }
- rets = heci_bh_write_handler(&complete_list, dev, &slots);
-end:
- DBG("end of bottom half function.\n");
- dev->host_hw_state = read_heci_register(dev, H_CSR);
- dev->host_buffer_is_empty = host_buffer_is_empty(dev);
-
- if ((dev->host_hw_state & H_IS) == H_IS) {
- /* acknowledge interrupt and disable interrupts */
- heci_csr_disable_interrupts(dev);
-
- DBG("schedule work the heci_bh_handler.\n");
- isr_pending = 1;
-
-
- } else {
- heci_csr_enable_interrupts(dev);
- }
-
- if (dev->recvd_msg) {
- DBG("received waiting bus message\n");
- bus_message_received = 1;
- }
-
- if (bus_message_received) {
- DBG("wake up dev->wait_recvd_msg\n");
- cv_broadcast(&dev->wait_recvd_msg);
- bus_message_received = 0;
- }
- if ((complete_list.status != 0) ||
- list_empty(&complete_list.heci_cb.cb_list)) {
- mutex_exit(&dev->device_lock);
- return (isr_pending);
- }
-
- mutex_exit(&dev->device_lock);
-
- list_for_each_entry_safe(cb_pos, cb_next,
- &complete_list.heci_cb.cb_list, cb_list, struct heci_cb_private) {
- file_ext = (struct heci_file_private *)cb_pos->file_private;
- list_del(&cb_pos->cb_list);
- if (file_ext != NULL) {
- if (file_ext != &dev->iamthif_file_ext) {
- DBG("completing call back.\n");
- _heci_cmpl(file_ext, cb_pos);
- cb_pos = NULL;
- } else if (file_ext == &dev->iamthif_file_ext) {
- _heci_cmpl_iamthif(dev, cb_pos);
- }
- }
- }
- return (isr_pending);
-}
-
-
-/*
- * heci_bh_read_handler - bottom half read routine after ISR to
- * handle the read processing.
- *
- * @cmpl_list: An instance of our list structure
- * @dev: Device object for our driver
- * @slots: slots to read.
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-heci_bh_read_handler(struct io_heci_list *cmpl_list,
- struct iamt_heci_device *dev,
- int32_t *slots)
-{
- struct heci_msg_hdr *heci_hdr;
- int ret = 0;
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
-
- if (!dev->rd_msg_hdr) {
- dev->rd_msg_hdr = read_heci_register(dev, ME_CB_RW);
- DBG("slots=%08x.\n", *slots);
- (*slots)--;
- DBG("slots=%08x.\n", *slots);
- }
- heci_hdr = (struct heci_msg_hdr *)&dev->rd_msg_hdr;
- DBG("heci_hdr->length =%d\n", heci_hdr->length);
-
- if ((heci_hdr->reserved) || !(dev->rd_msg_hdr)) {
- DBG("corrupted message header.\n");
- ret = -ECORRUPTED_MESSAGE_HEADER;
- goto end;
- }
-
- if ((heci_hdr->host_addr) || (heci_hdr->me_addr)) {
- list_for_each_entry_safe(file_pos, file_next,
- &dev->file_list, link, struct heci_file_private) {
- DBG("list_for_each_entry_safe read host"
- " client = %d, ME client = %d\n",
- file_pos->host_client_id,
- file_pos->me_client_id);
- if ((file_pos->host_client_id == heci_hdr->host_addr) &&
- (file_pos->me_client_id == heci_hdr->me_addr))
- break;
- }
-
- if (&file_pos->link == &dev->file_list) {
- DBG("corrupted message header\n");
- ret = -ECORRUPTED_MESSAGE_HEADER;
- goto end;
- }
- }
- if (((*slots) * sizeof (uint32_t)) < heci_hdr->length) {
- DBG("we can't read the message slots=%08x.\n", *slots);
- /* we can't read the message */
- ret = -ERANGE;
- goto end;
- }
-
- /* decide where to read the message too */
- if (!heci_hdr->host_addr) {
- DBG("call heci_bh_read_bus_message.\n");
- heci_bh_read_bus_message(dev, heci_hdr);
- DBG("end heci_bh_read_bus_message.\n");
- } else if ((heci_hdr->host_addr ==
- dev->iamthif_file_ext.host_client_id) &&
- (HECI_FILE_CONNECTED == dev->iamthif_file_ext.state) &&
- (dev->iamthif_state == HECI_IAMTHIF_READING)) {
-
- DBG("call heci_bh_read_iamthif_message.\n");
- DBG("heci_hdr->length =%d\n", heci_hdr->length);
- ret = heci_bh_read_pthi_message(cmpl_list, dev, heci_hdr);
- if (ret != 0)
- goto end;
-
- } else {
- DBG("call heci_bh_read_client_message.\n");
- ret = heci_bh_read_client_message(cmpl_list, dev, heci_hdr);
- if (ret != 0)
- goto end;
-
- }
-
- /* reset the number of slots and header */
- *slots = count_full_read_slots(dev);
- dev->rd_msg_hdr = 0;
-
- if (*slots == -ESLOTS_OVERFLOW) {
- /* overflow - reset */
- DBG("reseting due to slots overflow.\n");
- /* set the event since message has been read */
- ret = -ERANGE;
- goto end;
- }
-end:
- return (ret);
-}
-
-
-/*
- * heci_bh_read_bus_message - bottom half read routine after ISR to
- * handle the read bus message cmd processing.
- *
- * @dev: Device object for our driver
- * @heci_hdr: header of bus message
- */
-static void heci_bh_read_bus_message(struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr)
-{
- struct heci_bus_message *heci_msg;
- struct hbm_host_version_response *version_res;
- struct hbm_client_connect_response *connect_res;
- struct hbm_client_connect_response *disconnect_res;
- struct hbm_flow_control *flow_control;
- struct hbm_props_response *props_res;
- struct hbm_host_enum_response *enum_res;
- struct hbm_client_disconnect_request *disconnect_req;
- struct hbm_host_stop_request *h_stop_req;
- int i;
- unsigned char *buffer;
-
- /* read the message to our buffer */
- buffer = (unsigned char *)dev->rd_msg_buf;
- ASSERT(heci_hdr->length < sizeof (dev->rd_msg_buf));
- heci_read_slots(dev, buffer, heci_hdr->length);
- heci_msg = (struct heci_bus_message *)buffer;
-
- switch (*(uint8_t *)heci_msg) {
- case HOST_START_RES_CMD:
- version_res = (struct hbm_host_version_response *)heci_msg;
- if (version_res->host_version_supported) {
- dev->version.major_version = HBM_MAJOR_VERSION;
- dev->version.minor_version = HBM_MINOR_VERSION;
- } else {
- dev->version = version_res->me_max_version;
- }
- dev->recvd_msg = 1;
- DBG("host start response message received.\n");
- break;
-
- case CLIENT_CONNECT_RES_CMD:
- connect_res =
- (struct hbm_client_connect_response *)heci_msg;
- heci_client_connect_response(dev, connect_res);
- DBG("client connect response message received.\n");
- cv_broadcast(&dev->wait_recvd_msg);
- break;
-
- case CLIENT_DISCONNECT_RES_CMD:
- disconnect_res =
- (struct hbm_client_connect_response *)heci_msg;
- heci_client_disconnect_response(dev, disconnect_res);
- DBG("client disconnect response message received.\n");
- cv_broadcast(&dev->wait_recvd_msg);
- break;
-
- case HECI_FLOW_CONTROL_CMD:
- flow_control = (struct hbm_flow_control *)heci_msg;
- heci_client_flow_control_response(dev, flow_control);
- DBG("client flow control response message received.\n");
- break;
-
- case HOST_CLIENT_PROPERTEIS_RES_CMD:
- props_res = (struct hbm_props_response *)heci_msg;
- if (props_res->status != 0) {
- ASSERT(0);
- break;
- }
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id ==
- props_res->address) {
- dev->me_clients[i].props =
- props_res->client_properties;
- break;
- }
-
- }
- dev->recvd_msg = 1;
- break;
-
- case HOST_ENUM_RES_CMD:
- enum_res = (struct hbm_host_enum_response *)heci_msg;
- (void) memcpy(dev->heci_me_clients,
- enum_res->valid_addresses, 32);
- dev->recvd_msg = 1;
- break;
-
- case HOST_STOP_RES_CMD:
- dev->heci_state = HECI_DISABLED;
- DBG("reseting because of FW stop response.\n");
- heci_reset(dev, 1);
- break;
-
- case CLIENT_DISCONNECT_REQ_CMD:
- /* search for client */
- disconnect_req =
- (struct hbm_client_disconnect_request *)heci_msg;
- heci_client_disconnect_request(dev, disconnect_req);
- break;
-
- case ME_STOP_REQ_CMD:
- /* prepare stop request */
- heci_hdr = (struct heci_msg_hdr *)&dev->ext_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length = sizeof (struct hbm_host_stop_request);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
- h_stop_req =
- (struct hbm_host_stop_request *)&dev->ext_msg_buf[1];
- (void) memset(h_stop_req, 0,
- sizeof (struct hbm_host_stop_request));
- h_stop_req->cmd.cmd = HOST_STOP_REQ_CMD;
- h_stop_req->reason = DRIVER_STOP_REQUEST;
- h_stop_req->reserved[0] = 0;
- h_stop_req->reserved[1] = 0;
- dev->extra_write_index = 2;
- break;
-
- default:
- ASSERT(0);
- break;
-
- }
-}
-
-/*
- * heci_bh_read_pthi_message - bottom half read routine after ISR to
- * handle the read pthi message data processing.
- *
- * @complete_list: An instance of our list structure
- * @dev: Device object for our driver
- * @heci_hdr: header of pthi message
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-heci_bh_read_pthi_message(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr)
-{
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb;
- unsigned char *buffer;
-
- ASSERT(heci_hdr->me_addr == dev->iamthif_file_ext.me_client_id);
- ASSERT(dev->iamthif_state == HECI_IAMTHIF_READING);
-
- buffer = (unsigned char *)(dev->iamthif_msg_buf +
- dev->iamthif_msg_buf_index);
- ASSERT(sizeof (dev->iamthif_msg_buf) >=
- (dev->iamthif_msg_buf_index + heci_hdr->length));
-
- heci_read_slots(dev, buffer, heci_hdr->length);
-
- dev->iamthif_msg_buf_index += heci_hdr->length;
-
- if (!(heci_hdr->msg_complete))
- return (0);
-
- DBG("pthi_message_buffer_index=%d\n", heci_hdr->length);
- DBG("completed pthi read.\n ");
- if (!dev->iamthif_current_cb)
- return (-ENODEV);
-
- priv_cb = dev->iamthif_current_cb;
- dev->iamthif_current_cb = NULL;
-
- file_ext = (struct heci_file_private *)priv_cb->file_private;
- if (!file_ext)
- return (-ENODEV);
-
- dev->iamthif_stall_timer = 0;
- priv_cb->information = dev->iamthif_msg_buf_index;
- priv_cb->read_time = ddi_get_time();
- if ((dev->iamthif_ioctl) && (file_ext == &dev->iamthif_file_ext)) {
- /* found the iamthif cb */
- DBG("complete the pthi read cb.\n ");
- if (&dev->iamthif_file_ext) {
- DBG("add the pthi read cb to complete.\n ");
- list_add_tail(&priv_cb->cb_list,
- &complete_list->heci_cb.cb_list);
- }
- }
- return (0);
-}
-
-/*
- * _heci_bh_state_ok - check if heci header matches file private data
- *
- * @file_ext: private data of the file object
- * @heci_hdr: header of heci client message
- *
- * @return !=0 if matches, 0 if no match.
- */
-static int
-_heci_bh_state_ok(struct heci_file_private *file_ext,
- struct heci_msg_hdr *heci_hdr)
-{
- return ((file_ext->host_client_id == heci_hdr->host_addr) &&
- (file_ext->me_client_id == heci_hdr->me_addr) &&
- (file_ext->state == HECI_FILE_CONNECTED) &&
- (HECI_READ_COMPLETE != file_ext->reading_state));
-}
-
-/*
- * heci_bh_read_client_message - bottom half read routine after ISR to
- * handle the read heci client message data processing.
- *
- * @complete_list: An instance of our list structure
- * @dev: Device object for our driver
- * @heci_hdr: header of heci client message
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-heci_bh_read_client_message(struct io_heci_list *complete_list,
- struct iamt_heci_device *dev,
- struct heci_msg_hdr *heci_hdr)
-{
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb_pos = NULL, *priv_cb_next = NULL;
- unsigned char *buffer = NULL;
-
- DBG("start client msg\n");
- if (!((dev->read_list.status == 0) &&
- !list_empty(&dev->read_list.heci_cb.cb_list)))
- goto quit;
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->read_list.heci_cb.cb_list, cb_list, struct heci_cb_private) {
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if ((file_ext != NULL) &&
- (_heci_bh_state_ok(file_ext, heci_hdr))) {
- mutex_enter(&file_ext->read_io_lock);
- file_ext->reading_state = HECI_READING;
- buffer = (unsigned char *)
- (priv_cb_pos->response_buffer.data +
- priv_cb_pos->information);
- ASSERT(priv_cb_pos->response_buffer.size >=
- heci_hdr->length +
- priv_cb_pos->information);
-
- if (priv_cb_pos->response_buffer.size <
- heci_hdr->length +
- priv_cb_pos->information) {
- DBG("message overflow.\n");
- list_del(&priv_cb_pos->cb_list);
- mutex_exit(&file_ext->read_io_lock);
- return (-ENOMEM);
- }
- if (buffer) {
- heci_read_slots(dev, buffer,
- heci_hdr->length);
- }
- priv_cb_pos->information += heci_hdr->length;
- if (heci_hdr->msg_complete) {
- file_ext->status = 0;
- list_del(&priv_cb_pos->cb_list);
- mutex_exit(&file_ext->read_io_lock);
- DBG("completed read host client = %d,"
- "ME client = %d, "
- "data length = %lu\n",
- file_ext->host_client_id,
- file_ext->me_client_id,
- priv_cb_pos->information);
-
- DBG("priv_cb_pos->res_buffer - %s\n",
- priv_cb_pos->response_buffer.data);
- list_add_tail(&priv_cb_pos->cb_list,
- &complete_list->heci_cb.cb_list);
- } else {
- mutex_exit(&file_ext->read_io_lock);
- }
-
- break;
- }
-
- }
-
-quit:
- DBG("message read\n");
- if (!buffer) {
- heci_read_slots(dev, (unsigned char *)dev->rd_msg_buf,
- heci_hdr->length);
- DBG("discarding message, header=%08x.\n",
- *(uint32_t *)dev->rd_msg_buf);
- }
-
- return (0);
-}
-
-/*
- * _heci_bh_iamthif_read: prepare to read iamthif data.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_iamthif_read(struct iamt_heci_device *dev, int32_t *slots)
-{
-
- if (((*slots) * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr)
- + sizeof (struct hbm_flow_control))) {
- *slots -= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_flow_control) + 3) / 4;
- if (!heci_send_flow_control(dev, &dev->iamthif_file_ext)) {
- DBG("iamthif flow control failed\n");
- } else {
- DBG("iamthif flow control success\n");
- dev->iamthif_state = HECI_IAMTHIF_READING;
- dev->iamthif_flow_control_pending = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
- dev->host_buffer_is_empty = host_buffer_is_empty(dev);
- }
- return (0);
- } else {
- return (-ECOMPLETE_MESSAGE);
- }
-}
-
-/*
- * _heci_bh_close: process close related operation.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- * @priv_cb_pos: callback block.
- * @file_ext: private data of the file object.
- * @cmpl_list: complete list.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_close(struct iamt_heci_device *dev, int32_t *slots,
- struct heci_cb_private *priv_cb_pos,
- struct heci_file_private *file_ext,
- struct io_heci_list *cmpl_list)
-{
- if ((*slots * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_client_disconnect_request))) {
- *slots -= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_client_disconnect_request) + 3) / 4;
-
- if (!heci_disconnect(dev, file_ext)) {
- file_ext->status = 0;
- priv_cb_pos->information = 0;
- list_relink_node(&priv_cb_pos->cb_list,
- &cmpl_list->heci_cb.cb_list);
- return (-ECOMPLETE_MESSAGE);
- } else {
- file_ext->state = HECI_FILE_DISCONNECTING;
- file_ext->status = 0;
- priv_cb_pos->information = 0;
- list_relink_node(&priv_cb_pos->cb_list,
- &dev->ctrl_rd_list.heci_cb.cb_list);
- file_ext->timer_count = HECI_CONNECT_TIMEOUT;
- }
- } else {
- /* return the cancel routine */
- return (-ECORRUPTED_MESSAGE_HEADER);
- }
-
- return (0);
-}
-
-/*
- * _heci_hb_close: process read related operation.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- * @priv_cb_pos: callback block.
- * @file_ext: private data of the file object.
- * @cmpl_list: complete list.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_read(struct iamt_heci_device *dev, int32_t *slots,
- struct heci_cb_private *priv_cb_pos,
- struct heci_file_private *file_ext,
- struct io_heci_list *cmpl_list)
-{
- if ((*slots * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_flow_control))) {
- *slots -= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_flow_control) + 3) / 4;
- if (!heci_send_flow_control(dev, file_ext)) {
- file_ext->status = -ENODEV;
- priv_cb_pos->information = 0;
- list_relink_node(&priv_cb_pos->cb_list,
- &cmpl_list->heci_cb.cb_list);
- return (-ENODEV);
- } else {
- list_relink_node(&priv_cb_pos->cb_list,
- &dev->read_list.heci_cb.cb_list);
- }
- } else {
- /* return the cancel routine */
- list_del(&priv_cb_pos->cb_list);
- return (-ECORRUPTED_MESSAGE_HEADER);
- }
-
- return (0);
-}
-
-
-/*
- * _heci_bh_ioctl: process ioctl related operation.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- * @priv_cb_pos: callback block.
- * @file_ext: private data of the file object.
- * @cmpl_list: complete list.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_ioctl(struct iamt_heci_device *dev, int32_t *slots,
- struct heci_cb_private *priv_cb_pos,
- struct heci_file_private *file_ext,
- struct io_heci_list *cmpl_list)
-{
- _NOTE(ARGUNUSED(cmpl_list));
-
- if ((*slots * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_client_connect_request))) {
- file_ext->state = HECI_FILE_CONNECTING;
- *slots -= (sizeof (struct heci_msg_hdr) +
- sizeof (struct hbm_client_connect_request) + 3) / 4;
- if (!heci_connect(dev, file_ext)) {
- file_ext->status = -ENODEV;
- priv_cb_pos->information = 0;
- list_del(&priv_cb_pos->cb_list);
- return (-ENODEV);
- } else {
- list_relink_node(&priv_cb_pos->cb_list,
- &dev->ctrl_rd_list.heci_cb.cb_list);
- file_ext->timer_count = HECI_CONNECT_TIMEOUT;
- }
- } else {
- /* return the cancel routine */
- list_del(&priv_cb_pos->cb_list);
- return (-ECORRUPTED_MESSAGE_HEADER);
- }
-
- return (0);
-}
-
-/*
- * _heci_bh_cmpl: process completed and no-iamthif operation.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- * @priv_cb_pos: callback block.
- * @file_ext: private data of the file object.
- * @cmpl_list: complete list.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_cmpl(struct iamt_heci_device *dev, int32_t *slots,
- struct heci_cb_private *priv_cb_pos,
- struct heci_file_private *file_ext,
- struct io_heci_list *cmpl_list)
-{
- struct heci_msg_hdr *heci_hdr;
-
- if ((*slots * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr) +
- (priv_cb_pos->request_buffer.size -
- priv_cb_pos->information))) {
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = file_ext->host_client_id;
- heci_hdr->me_addr = file_ext->me_client_id;
- heci_hdr->length = ((priv_cb_pos->request_buffer.size) -
- (priv_cb_pos->information));
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
- DBG("priv_cb_pos->request_buffer.size =%d"
- "heci_hdr->msg_complete= %d\n",
- priv_cb_pos->request_buffer.size,
- heci_hdr->msg_complete);
- DBG("priv_cb_pos->information =%lu\n",
- priv_cb_pos->information);
- DBG("heci_hdr->length =%d\n",
- heci_hdr->length);
- *slots -= (sizeof (struct heci_msg_hdr) +
- heci_hdr->length + 3) / 4;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)(priv_cb_pos->request_buffer.data +
- priv_cb_pos->information),
- heci_hdr->length)) {
- file_ext->status = -ENODEV;
- list_relink_node(&priv_cb_pos->cb_list,
- &cmpl_list->heci_cb.cb_list);
- return (-ENODEV);
- } else {
- flow_ctrl_reduce(dev, file_ext);
- file_ext->status = 0;
- priv_cb_pos->information += heci_hdr->length;
- list_relink_node(&priv_cb_pos->cb_list,
- &dev->write_waiting_list.heci_cb.cb_list);
- }
- } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
- /* buffer is still empty */
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = file_ext->host_client_id;
- heci_hdr->me_addr = file_ext->me_client_id;
- heci_hdr->length =
- (*slots * sizeof (uint32_t)) - sizeof (struct heci_msg_hdr);
- heci_hdr->msg_complete = 0;
- heci_hdr->reserved = 0;
-
- (*slots) -= (sizeof (struct heci_msg_hdr) +
- heci_hdr->length + 3) / 4;
- if (!heci_write_message(dev, heci_hdr,
- (unsigned char *)
- (priv_cb_pos->request_buffer.data +
- priv_cb_pos->information),
- heci_hdr->length)) {
- file_ext->status = -ENODEV;
- list_relink_node(&priv_cb_pos->cb_list,
- &cmpl_list->heci_cb.cb_list);
- return (-ENODEV);
- } else {
- priv_cb_pos->information += heci_hdr->length;
- DBG("priv_cb_pos->request_buffer.size =%d"
- " heci_hdr->msg_complete= %d\n",
- priv_cb_pos->request_buffer.size,
- heci_hdr->msg_complete);
- DBG("priv_cb_pos->information =%lu\n",
- priv_cb_pos->information);
- DBG("heci_hdr->length =%d\n", heci_hdr->length);
- }
- return (-ECOMPLETE_MESSAGE);
- } else {
- return (-ECORRUPTED_MESSAGE_HEADER);
- }
-
- return (0);
-}
-
-/*
- * _heci_bh_cmpl_iamthif: process completed iamthif operation.
- *
- * @dev: Device object for our driver.
- * @slots: free slots.
- * @priv_cb_pos: callback block.
- * @file_ext: private data of the file object.
- * @cmpl_list: complete list.
- *
- * @return 0, OK; otherwise, error.
- */
-static int
-_heci_bh_cmpl_iamthif(struct iamt_heci_device *dev, int32_t *slots,
- struct heci_cb_private *priv_cb_pos,
- struct heci_file_private *file_ext,
- struct io_heci_list *cmpl_list)
-{
- struct heci_msg_hdr *heci_hdr;
-
- _NOTE(ARGUNUSED(cmpl_list));
-
- if ((*slots * sizeof (uint32_t)) >= (sizeof (struct heci_msg_hdr) +
- dev->iamthif_msg_buf_size -
- dev->iamthif_msg_buf_index)) {
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = file_ext->host_client_id;
- heci_hdr->me_addr = file_ext->me_client_id;
- heci_hdr->length = dev->iamthif_msg_buf_size -
- dev->iamthif_msg_buf_index;
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- *slots -= (sizeof (struct heci_msg_hdr) +
- heci_hdr->length + 3) / 4;
-
- if (!heci_write_message(dev, heci_hdr,
- (dev->iamthif_msg_buf +
- dev->iamthif_msg_buf_index),
- heci_hdr->length)) {
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
- file_ext->status = -ENODEV;
- list_del(&priv_cb_pos->cb_list);
- return (-ENODEV);
- } else {
- flow_ctrl_reduce(dev, file_ext);
- dev->iamthif_msg_buf_index += heci_hdr->length;
- priv_cb_pos->information = dev->iamthif_msg_buf_index;
- file_ext->status = 0;
- dev->iamthif_state = HECI_IAMTHIF_FLOW_CONTROL;
- dev->iamthif_flow_control_pending = 1;
- /* save iamthif cb sent to pthi client */
- dev->iamthif_current_cb = priv_cb_pos;
- list_relink_node(&priv_cb_pos->cb_list,
- &dev->write_waiting_list.heci_cb.cb_list);
-
- }
- } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
- /* buffer is still empty */
- heci_hdr = (struct heci_msg_hdr *)&dev->wr_msg_buf[0];
- heci_hdr->host_addr = file_ext->host_client_id;
- heci_hdr->me_addr = file_ext->me_client_id;
- heci_hdr->length =
- (*slots * sizeof (uint32_t)) - sizeof (struct heci_msg_hdr);
- heci_hdr->msg_complete = 0;
- heci_hdr->reserved = 0;
-
- *slots -= (sizeof (struct heci_msg_hdr) +
- heci_hdr->length + 3) / 4;
-
- if (!heci_write_message(dev, heci_hdr,
- (dev->iamthif_msg_buf +
- dev->iamthif_msg_buf_index),
- heci_hdr->length)) {
- file_ext->status = -ENODEV;
- list_del(&priv_cb_pos->cb_list);
- } else {
- dev->iamthif_msg_buf_index += heci_hdr->length;
- }
- return (-ECOMPLETE_MESSAGE);
- } else {
- return (-ECORRUPTED_MESSAGE_HEADER);
- }
-
- return (0);
-}
-
-/*
- * heci_bh_write_handler - bottom half write routine after
- * ISR to handle the write processing.
- *
- * @cmpl_list: An instance of our list structure
- * @dev: Device object for our driver
- * @slots: slots to write.
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-heci_bh_write_handler(struct io_heci_list *cmpl_list,
- struct iamt_heci_device *dev,
- int32_t *slots)
-{
-
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb_pos = NULL, *priv_cb_next = NULL;
- struct io_heci_list *list;
- int ret;
-
- if (!host_buffer_is_empty(dev)) {
- DBG("host buffer is not empty.\n");
- return (0);
- }
- dev->write_hang = (uint8_t)-1;
- *slots = count_empty_write_slots(dev);
- /* complete all waiting for write CB */
- DBG("complete all waiting for write cb.\n");
-
- list = &dev->write_waiting_list;
- if ((list->status == 0) &&
- !list_empty(&list->heci_cb.cb_list)) {
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &list->heci_cb.cb_list, cb_list, struct heci_cb_private) {
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if (file_ext != NULL) {
- file_ext->status = 0;
- list_del(&priv_cb_pos->cb_list);
- if ((HECI_WRITING == file_ext->writing_state) &&
- (priv_cb_pos->major_file_operations ==
- HECI_WRITE) &&
- (file_ext != &dev->iamthif_file_ext)) {
- DBG("HECI WRITE COMPLETE\n");
- file_ext->writing_state =
- HECI_WRITE_COMPLETE;
- list_add_tail(&priv_cb_pos->cb_list,
- &cmpl_list->heci_cb.cb_list);
- }
- if (file_ext == &dev->iamthif_file_ext) {
- DBG("check iamthif flow control.\n");
- if (dev->iamthif_flow_control_pending) {
- ret = _heci_bh_iamthif_read(dev,
- slots);
- if (ret != 0)
- return (ret);
- }
- }
- }
-
- }
- }
-
- if ((dev->stop) && (!dev->wd_pending)) {
- dev->wd_stoped = 1;
- cv_broadcast(&dev->wait_stop_wd);
- return (0);
- }
-
- if (dev->extra_write_index != 0) {
- DBG("extra_write_index =%d.\n", dev->extra_write_index);
- if (!heci_write_message(dev,
- (struct heci_msg_hdr *)&dev->ext_msg_buf[0],
- (unsigned char *)&dev->ext_msg_buf[1],
- (dev->extra_write_index - 1) * sizeof (uint32_t))) {
- DBG("heci_bh_handler: writing msg failed\n");
- }
- *slots -= dev->extra_write_index;
- dev->extra_write_index = 0;
- }
- if (dev->heci_state == HECI_ENABLED) {
- if (dev->wd_pending &&
- flow_ctrl_creds(dev, &dev->wd_file_ext)) {
- if (!heci_send_wd(dev)) {
- DBG("wd send failed.\n");
- } else
- flow_ctrl_reduce(dev, &dev->wd_file_ext);
-
- dev->wd_pending = 0;
-
- if (dev->wd_timeout != 0) {
- *slots -= (sizeof (struct heci_msg_hdr) +
- HECI_START_WD_DATA_SIZE + 3) / 4;
- dev->wd_due_counter = 2;
- } else {
- *slots -= (sizeof (struct heci_msg_hdr) +
- HECI_WD_PARAMS_SIZE + 3) / 4;
- dev->wd_due_counter = 0;
- }
-
- }
- }
- if (dev->stop)
- return (~ENODEV);
-
- /* complete control write list CB */
- if (dev->ctrl_wr_list.status == 0) {
- /* complete control write list CB */
- DBG("complete control write list cb.\n");
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->ctrl_wr_list.heci_cb.cb_list,
- cb_list, struct heci_cb_private) {
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if (file_ext == NULL) {
- list_del(&priv_cb_pos->cb_list);
- return (-ENODEV);
- }
- switch (priv_cb_pos->major_file_operations) {
- case HECI_CLOSE:
- /* send disconnect message */
- ret = _heci_bh_close(dev, slots,
- priv_cb_pos,
- file_ext, cmpl_list);
- if (ret != 0)
- return (ret);
-
- break;
- case HECI_READ:
- /* send flow control message */
- ret = _heci_bh_read(dev, slots,
- priv_cb_pos,
- file_ext, cmpl_list);
- if (ret != 0)
- return (ret);
-
- break;
- case HECI_IOCTL:
- /* connect message */
- if (!other_client_is_connecting(dev, file_ext))
- continue;
- ret = _heci_bh_ioctl(dev, slots,
- priv_cb_pos,
- file_ext, cmpl_list);
- if (ret != 0)
- return (ret);
-
- break;
-
- default:
- ASSERT(0);
- }
-
- }
- }
- /* complete write list CB */
- if ((dev->write_list.status == 0) &&
- !list_empty(&dev->write_list.heci_cb.cb_list)) {
-
- DBG("complete write list cb.\n");
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->write_list.heci_cb.cb_list,
- cb_list, struct heci_cb_private) {
-
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if (file_ext != NULL) {
- if (file_ext != &dev->iamthif_file_ext) {
- if (!flow_ctrl_creds(dev, file_ext)) {
- DBG("No flow control"
- " credentials for client"
- " %d, not sending.\n",
- file_ext->host_client_id);
- continue;
- }
- ret = _heci_bh_cmpl(dev, slots,
- priv_cb_pos, file_ext, cmpl_list);
- if (ret != 0)
- return (ret);
-
- } else if (file_ext == &dev->iamthif_file_ext) {
- /* IAMTHIF IOCTL */
- DBG("complete pthi write cb.\n");
- if (!flow_ctrl_creds(dev, file_ext)) {
- DBG("No flow control"
- " credentials for pthi"
- " client %d.\n",
- file_ext->host_client_id);
- continue;
- }
- ret = _heci_bh_cmpl_iamthif(dev, slots,
- priv_cb_pos, file_ext, cmpl_list);
- if (ret != 0)
- return (ret);
-
- }
- }
-
- }
- }
- return (0);
-}
-
-
-/*
- * is_treat_specially_client - check if the message belong
- * to the file private data.
- *
- * @file_ext: private data of the file object
- * @rs: connect response bus message
- * @dev: Device object for our driver
- *
- * @return 0 on success, <0 on failure.
- */
-static int
-is_treat_specially_client(struct heci_file_private *file_ext,
- struct hbm_client_connect_response *rs)
-{
- int ret = 0;
-
- if ((file_ext->host_client_id == rs->host_addr) &&
- (file_ext->me_client_id == rs->me_addr)) {
- if (rs->status == 0) {
- DBG("client connect status = 0x%08x.\n", rs->status);
- file_ext->state = HECI_FILE_CONNECTED;
- file_ext->status = 0;
- } else {
- DBG("client connect status = 0x%08x.\n", rs->status);
- file_ext->state = HECI_FILE_DISCONNECTED;
- file_ext->status = -ENODEV;
- }
- ret = 1;
- }
- DBG("client state = %d.\n", file_ext->state);
- return (ret);
-}
-
-/*
- * heci_client_connect_response - connect response bh routine
- *
- * @dev: Device object for our driver
- * @rs: connect response bus message
- */
-static void
-heci_client_connect_response(struct iamt_heci_device *dev,
- struct hbm_client_connect_response *rs)
-{
-
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb_pos = NULL, *priv_cb_next = NULL;
-
- /* if WD or iamthif client treat specially */
-
- if ((is_treat_specially_client(&(dev->wd_file_ext), rs)) ||
- (is_treat_specially_client(&(dev->iamthif_file_ext), rs)))
- return;
-
- if (dev->ctrl_rd_list.status == 0 &&
- !list_empty(&dev->ctrl_rd_list.heci_cb.cb_list)) {
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->ctrl_rd_list.heci_cb.cb_list,
- cb_list, struct heci_cb_private) {
-
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if (file_ext == NULL) {
- list_del(&priv_cb_pos->cb_list);
- return;
- }
- if (HECI_IOCTL == priv_cb_pos->major_file_operations) {
- if (is_treat_specially_client(file_ext, rs)) {
- list_del(&priv_cb_pos->cb_list);
- file_ext->status = 0;
- file_ext->timer_count = 0;
- break;
- }
- }
- }
- }
-}
-
-/*
- * heci_client_disconnect_response - disconnect response bh routine
- *
- * @dev: Device object for our driver
- * @rs: disconnect response bus message
- */
-static void heci_client_disconnect_response(struct iamt_heci_device *dev,
- struct hbm_client_connect_response *rs)
-{
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb_pos = NULL, *priv_cb_next = NULL;
-
- if (dev->ctrl_rd_list.status == 0 &&
- !list_empty(&dev->ctrl_rd_list.heci_cb.cb_list)) {
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->ctrl_rd_list.heci_cb.cb_list,
- cb_list, struct heci_cb_private) {
-
- file_ext = (struct heci_file_private *)
- priv_cb_pos->file_private;
-
- if (file_ext == NULL) {
- list_del(&priv_cb_pos->cb_list);
- return;
- }
-
- DBG("list_for_each_entry_safe in ctrl_rd_list.\n");
- if ((file_ext->host_client_id == rs->host_addr) &&
- (file_ext->me_client_id == rs->me_addr)) {
-
- list_del(&priv_cb_pos->cb_list);
- if (rs->status == 0) {
- file_ext->state =
- HECI_FILE_DISCONNECTED;
- }
-
- file_ext->status = 0;
- file_ext->timer_count = 0;
- break;
- }
- }
- }
-}
-
-/*
- * same_flow_addr - tell they have same address.
- *
- * @file: private data of the file object.
- * @flow: flow control.
- *
- * @return !=0, same; 0,not.
- */
-static int
-same_flow_addr(struct heci_file_private *file,
- struct hbm_flow_control *flow)
-{
- return ((file->host_client_id == flow->host_addr) &&
- (file->me_client_id == flow->me_addr));
-}
-
-/*
- * add_single_flow_creds - add single buffer credentials.
- *
- * @file: private data ot the file object.
- * @flow: flow control.
- */
-static void
-add_single_flow_creds(struct iamt_heci_device *dev,
- struct hbm_flow_control *flow)
-{
- struct heci_me_client *client;
- int i;
-
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- client = &dev->me_clients[i];
- if ((client != NULL) &&
- (flow->me_addr == client->client_id)) {
- if (client->props.single_recv_buf != 0) {
- client->flow_ctrl_creds++;
- DBG("recv flow ctrl msg ME %d (single).\n",
- flow->me_addr);
- DBG("flow control credentials=%d.\n",
- client->flow_ctrl_creds);
- } else {
- ASSERT(0); /* error in flow control */
- }
- }
- }
-}
-/*
- * heci_client_flow_control_response - flow control response bh routine
- *
- * @dev: Device object for our driver
- * @flow_control: flow control response bus message
- */
-static void
-heci_client_flow_control_response(struct iamt_heci_device *dev,
- struct hbm_flow_control *flow_control)
-{
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
-
- if (flow_control->host_addr == 0) {
- /* single receive buffer */
- add_single_flow_creds(dev, flow_control);
- } else {
- /* normal connection */
- list_for_each_entry_safe(file_pos, file_next,
- &dev->file_list, link, struct heci_file_private) {
- DBG("list_for_each_entry_safe in file_list\n");
-
- DBG("file_ext of host client %d ME client %d.\n",
- file_pos->host_client_id,
- file_pos->me_client_id);
- DBG("flow ctrl msg for host %d ME %d.\n",
- flow_control->host_addr,
- flow_control->me_addr);
- if (same_flow_addr(file_pos, flow_control)) {
- DBG("recv ctrl msg for host %d ME %d.\n",
- flow_control->host_addr,
- flow_control->me_addr);
- file_pos->flow_ctrl_creds++;
- DBG("flow control credentials=%d.\n",
- file_pos->flow_ctrl_creds);
- break;
- }
- }
- }
-}
-
-/*
- * same_disconn_addr - tell they have same address
- *
- * @file: private data of the file object.
- * @disconn: disconnection request.
- *
- * @return !=0, same; 0,not.
- */
-static int
-same_disconn_addr(struct heci_file_private *file,
- struct hbm_client_disconnect_request *disconn)
-{
- return ((file->host_client_id == disconn->host_addr) &&
- (file->me_client_id == disconn->me_addr));
-}
-
-/*
- * heci_client_disconnect_request - disconnect request bh routine
- *
- * @dev: Device object for our driver.
- * @disconnect_req: disconnect request bus message.
- */
-static void
-heci_client_disconnect_request(struct iamt_heci_device *dev,
- struct hbm_client_disconnect_request *disconnect_req)
-{
- struct heci_msg_hdr *heci_hdr;
- struct hbm_client_connect_response *disconnect_res;
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
-
- list_for_each_entry_safe(file_pos, file_next, &dev->file_list,
- link, struct heci_file_private) {
-
- if (same_disconn_addr(file_pos, disconnect_req)) {
- DBG("disconnect request host client %d ME client %d.\n",
- disconnect_req->host_addr,
- disconnect_req->me_addr);
- file_pos->state = HECI_FILE_DISCONNECTED;
- file_pos->timer_count = 0;
- if (file_pos == &dev->wd_file_ext) {
- dev->wd_due_counter = 0;
- dev->wd_pending = 0;
- } else if (file_pos == &dev->iamthif_file_ext)
- dev->iamthif_timer = 0;
-
- /* prepare disconnect response */
- heci_hdr =
- (struct heci_msg_hdr *)&dev->ext_msg_buf[0];
- heci_hdr->host_addr = 0;
- heci_hdr->me_addr = 0;
- heci_hdr->length =
- sizeof (struct hbm_client_connect_response);
- heci_hdr->msg_complete = 1;
- heci_hdr->reserved = 0;
-
- disconnect_res =
- (struct hbm_client_connect_response *)
- &dev->ext_msg_buf[1];
- disconnect_res->host_addr = file_pos->host_client_id;
- disconnect_res->me_addr = file_pos->me_client_id;
- *(uint8_t *)(&disconnect_res->cmd) =
- CLIENT_DISCONNECT_RES_CMD;
- disconnect_res->status = 0;
- dev->extra_write_index = 2;
- break;
- }
- }
-}
-
-/*
- * heci_timer - timer function.
- *
- * @data: pointer to the device structure
- *
- * NOTE: This function is called by timer interrupt work
- */
-void
-heci_wd_timer(void *data)
-{
- struct iamt_heci_device *dev = (struct iamt_heci_device *)data;
-
- DBG("send watchdog.\n");
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
- mutex_exit(&dev->device_lock);
- return;
- }
- if (dev->wd_file_ext.state != HECI_FILE_CONNECTED) {
- dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
- mutex_exit(&dev->device_lock);
- return;
- }
- /* Watchdog */
- if ((dev->wd_due_counter != 0) && (dev->wd_bypass == 0)) {
- if (--dev->wd_due_counter == 0) {
- if (dev->host_buffer_is_empty &&
- flow_ctrl_creds(dev, &dev->wd_file_ext)) {
- dev->host_buffer_is_empty = 0;
- if (!heci_send_wd(dev)) {
- DBG("wd send failed.\n");
- } else {
- flow_ctrl_reduce(dev,
- &dev->wd_file_ext);
- }
-
- if (dev->wd_timeout != 0)
- dev->wd_due_counter = 2;
- else
- dev->wd_due_counter = 0;
-
- } else
- dev->wd_pending = 1;
-
- }
- }
- if (dev->iamthif_stall_timer != 0) {
- if (--dev->iamthif_stall_timer == 0) {
- DBG("reseting because of hang to PTHI.\n");
- heci_reset(dev, 1);
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = 0;
- dev->iamthif_ioctl = 1;
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
- mutex_exit(&dev->device_lock);
-
- if (dev->iamthif_current_cb)
- heci_free_cb_private(dev->iamthif_current_cb);
-
- mutex_enter(&dev->device_lock);
- dev->iamthif_file_object = NULL;
- dev->iamthif_current_cb = NULL;
- run_next_iamthif_cmd(dev);
- }
- }
- dev->wd_timer = timeout(heci_wd_timer, data, 2 * HZ);
- mutex_exit(&dev->device_lock);
-}
diff --git a/usr/src/uts/intel/io/heci/heci_main.c b/usr/src/uts/intel/io/heci/heci_main.c
deleted file mode 100644
index 2dc0180cd5..0000000000
--- a/usr/src/uts/intel/io/heci/heci_main.c
+++ /dev/null
@@ -1,1535 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#pragma ident "@(#)heci_main.c 1.7 08/03/07 SMI"
-
-#include <sys/types.h>
-#include <sys/note.h>
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/ddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/devops.h>
-#include <sys/instance.h>
-#include <sys/modctl.h>
-#include <sys/open.h>
-#include <sys/stat.h>
-#include <sys/sunddi.h>
-#include <sys/file.h>
-#include <sys/priv.h>
-#include <sys/systm.h>
-#include <sys/mkdev.h>
-#include <sys/list.h>
-#include <sys/pci.h>
-#include "heci_data_structures.h"
-
-#include "heci.h"
-#include "heci_interface.h"
-
-#define MAJOR_VERSION 5
-#define MINOR_VERSION 0
-#define QUICK_FIX_NUMBER 0
-#define VER_BUILD 30
-
-#define str(s) name(s)
-#define name(s) #s
-#define HECI_DRIVER_VERSION str(MAJOR_VERSION) "." str(MINOR_VERSION) \
- "." str(QUICK_FIX_NUMBER) "." str(VER_BUILD)
-
-#define HECI_READ_TIMEOUT 45
-
-#define HECI_DRIVER_NAME "heci"
-
-/*
- * heci driver strings
- */
-char heci_driver_name[] = HECI_DRIVER_NAME;
-char heci_driver_string[] = "Intel(R) Management Engine Interface";
-char heci_driver_version[] = HECI_DRIVER_VERSION;
-char heci_copyright[] = "Copyright (c) 2003 - 2008 Intel Corporation.";
-
-void * heci_soft_state_p = NULL;
-
-#ifdef DEBUG
-int heci_debug = 0;
-#endif
-
-/*
- * Local Function Prototypes
- */
-static int heci_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
-static int heci_initialize(dev_info_t *dip, struct iamt_heci_device *device);
-static int heci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd,
- void *arg, void **result);
-static int heci_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
-static int heci_quiesce(dev_info_t *dip);
-static int heci_open(dev_t *devp, int flags, int otyp, cred_t *credp);
-static int heci_close(dev_t dev, int flag, int otyp, struct cred *cred);
-static int heci_read(dev_t dev, struct uio *uio_p, cred_t *cred_p);
-static int heci_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
- cred_t *cr, int *rval);
-static int heci_write(dev_t dev, struct uio *uio_p, struct cred *cred);
-static int heci_poll(dev_t dev, short events, int anyyet,
- short *reventsp, struct pollhead **phpp);
-static struct heci_cb_private *find_read_list_entry(
- struct iamt_heci_device *dev,
- struct heci_file_private *file_ext);
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2);
-
-static void heci_resume(dev_info_t *dip);
-static int heci_suspend(dev_info_t *dip);
-static uint16_t g_sus_wd_timeout;
-
-static struct cb_ops heci_cb_ops = {
- heci_open, /* open */
- heci_close, /* close */
- nodev, /* strategy */
- nodev, /* print */
- nodev, /* dump */
- heci_read, /* read */
- heci_write, /* write */
- heci_ioctl, /* ioctl */
- nodev, /* devmap */
- nodev, /* mmap */
- nodev, /* segmap */
- heci_poll, /* poll */
- ddi_prop_op, /* cb_prop op */
- NULL, /* stream tab */
- D_MP /* Driver Compatability Flags */
-};
-
-static struct dev_ops heci_dev_ops = {
- DEVO_REV, /* devo_rev */
- 0, /* refcnt */
- heci_getinfo, /* get_dev_info */
- nulldev, /* identify */
- nulldev, /* probe */
- heci_attach, /* attach */
- heci_detach, /* detach */
- nodev, /* reset */
- &heci_cb_ops, /* Driver Ops */
- (struct bus_ops *)NULL, /* Bus Operations */
- NULL, /* power */
- heci_quiesce /* devo_quiesce */
-};
-
-/*
- * Module linkage information for the kernel
- */
-
-static struct modldrv modldrv = {
- &mod_driverops, /* Type of Module = Driver */
- heci_driver_string, /* Driver Identifier string. */
- &heci_dev_ops, /* Driver Ops. */
-};
-
-static struct modlinkage modlinkage = {
- MODREV_1, (void *)&modldrv, NULL
-};
-
-/*
- * Module Initialization functions.
- */
-
-int
-_init(void)
-{
- int stat;
-
- /* Allocate soft state */
- if ((stat = ddi_soft_state_init(&heci_soft_state_p,
- sizeof (struct iamt_heci_device), 1)) != DDI_SUCCESS) {
- return (stat);
- }
-
- if ((stat = mod_install(&modlinkage)) != 0)
- ddi_soft_state_fini(&heci_soft_state_p);
-
- return (stat);
-}
-
-int
-_info(struct modinfo *infop)
-{
-
- return (mod_info(&modlinkage, infop));
-}
-
-int
-_fini(void)
-{
- int stat;
-
- if ((stat = mod_remove(&modlinkage)) != 0)
- return (stat);
-
- ddi_soft_state_fini(&heci_soft_state_p);
-
- return (stat);
-}
-
-/*
- * heci_attach - Driver Attach Routine
- */
-static int
-heci_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
-{
- int instance, status;
- struct iamt_heci_device *device;
-
- switch (cmd) {
- case DDI_ATTACH:
- break;
- case DDI_RESUME:
- heci_resume(dip);
- return (DDI_SUCCESS);
- default:
- return (DDI_FAILURE);
- }
-
- DBG("%s - version %s\n", heci_driver_string, heci_driver_version);
- DBG("%s\n", heci_copyright);
-
- instance = ddi_get_instance(dip); /* find out which unit */
- status = ddi_soft_state_zalloc(heci_soft_state_p, instance);
- if (status != DDI_SUCCESS)
- return (DDI_FAILURE);
- device = ddi_get_soft_state(heci_soft_state_p, instance);
- ASSERT(device != NULL); /* can't fail - we only just allocated it */
-
- device->dip = dip;
-
- status = heci_initialize(dip, device);
- if (status != DDI_SUCCESS) {
- ddi_soft_state_free(heci_soft_state_p, instance);
- return (DDI_FAILURE);
- }
-
- status = ddi_create_minor_node(dip, "AMT", S_IFCHR,
- MAKE_MINOR_NUM(HECI_MINOR_NUMBER, instance),
- DDI_PSEUDO, 0);
-
- if (status != DDI_SUCCESS) {
-
- ddi_remove_minor_node(dip, NULL);
- ddi_soft_state_free(heci_soft_state_p, instance);
- return (DDI_FAILURE);
- }
-
-
- return (status);
-}
-
-/*
- * heci_probe - Device Initialization Routine
- */
-static int
-heci_initialize(dev_info_t *dip, struct iamt_heci_device *device)
-{
- int err;
- ddi_device_acc_attr_t attr;
-
- err = ddi_get_iblock_cookie(dip, 0, &device->sc_iblk);
- if (err != DDI_SUCCESS) {
- cmn_err(CE_WARN, "heci_probe():"
- " ddi_get_iblock_cookie() failed\n");
- goto end;
- }
- /* initializes the heci device structure */
- init_heci_device(dip, device);
-
- attr.devacc_attr_version = DDI_DEVICE_ATTR_V0;
- attr.devacc_attr_endian_flags = DDI_STRUCTURE_LE_ACC;
- attr.devacc_attr_dataorder = DDI_STRICTORDER_ACC;
-
- if (ddi_regs_map_setup(dip, 1, (caddr_t *)&device->mem_addr, 0, 0,
- &attr, &device->io_handle) != DDI_SUCCESS) {
- cmn_err(CE_WARN, "heci%d: unable to map PCI regs\n",
- ddi_get_instance(dip));
- goto fini_heci_device;
- }
-
- err = ddi_add_intr(dip, 0, &device->sc_iblk, NULL,
- heci_isr_interrupt, (caddr_t)device);
- if (err != DDI_SUCCESS) {
- cmn_err(CE_WARN, "heci_probe(): ddi_add_intr() failed\n");
- goto unmap_memory;
- }
-
- if (heci_hw_init(device)) {
- cmn_err(CE_WARN, "init hw failure.\n");
- err = -ENODEV;
- goto release_irq;
- }
- (void) heci_initialize_clients(device);
- if (device->heci_state != HECI_ENABLED) {
- err = -ENODEV;
- goto release_hw;
- }
- if (device->wd_timeout)
- device->wd_timer = timeout(heci_wd_timer, device, 1);
-
- DBG("heci driver initialization successful.\n");
- return (0);
-
-release_hw:
- /* disable interrupts */
- device->host_hw_state = read_heci_register(device, H_CSR);
- heci_csr_disable_interrupts(device);
-
-release_irq:
- ddi_remove_intr(dip, 0, device->sc_iblk);
-unmap_memory:
- if (device->mem_addr)
- ddi_regs_map_free(&device->io_handle);
-fini_heci_device:
- fini_heci_device(device);
-end:
- cmn_err(CE_WARN, "heci driver initialization failed.\n");
- return (err);
-}
-
-void
-heci_destroy_locks(struct iamt_heci_device *device_object)
-{
-
- mutex_destroy(&device_object->iamthif_file_ext.file_lock);
- mutex_destroy(&device_object->iamthif_file_ext.read_io_lock);
- mutex_destroy(&device_object->iamthif_file_ext.write_io_lock);
-
- mutex_destroy(&device_object->wd_file_ext.file_lock);
- mutex_destroy(&device_object->wd_file_ext.read_io_lock);
- mutex_destroy(&device_object->wd_file_ext.write_io_lock);
- mutex_destroy(&device_object->device_lock);
-
- cv_destroy(&device_object->iamthif_file_ext.rx_wait);
- cv_destroy(&device_object->wd_file_ext.rx_wait);
- cv_destroy(&device_object->wait_recvd_msg);
- cv_destroy(&device_object->wait_stop_wd);
-}
-
-/*
- * heci_remove - Device Removal Routine
- *
- * @pdev: PCI device information struct
- *
- * heci_remove is called by the PCI subsystem to alert the driver
- * that it should release a PCI device.
- */
-static int
-heci_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
-{
- struct iamt_heci_device *dev;
- int err;
-
- dev = ddi_get_soft_state(heci_soft_state_p, ddi_get_instance(dip));
- ASSERT(dev != NULL);
-
- switch (cmd) {
- case DDI_SUSPEND:
- err = heci_suspend(dip);
- if (err)
- return (DDI_FAILURE);
- else
- return (DDI_SUCCESS);
-
- case DDI_DETACH:
- break;
-
- default:
- return (DDI_FAILURE);
- }
-
- if (dev->wd_timer)
- (void) untimeout(dev->wd_timer);
-
- mutex_enter(&dev->device_lock);
- if (dev->wd_file_ext.state == HECI_FILE_CONNECTED &&
- dev->wd_timeout) {
- dev->wd_timeout = 0;
- dev->wd_due_counter = 0;
- (void) memcpy(dev->wd_data, stop_wd_params,
- HECI_WD_PARAMS_SIZE);
- dev->stop = 1;
- if (dev->host_buffer_is_empty &&
- flow_ctrl_creds(dev, &dev->wd_file_ext)) {
- dev->host_buffer_is_empty = 0;
-
- if (!heci_send_wd(dev)) {
- DBG("send stop WD failed\n");
- } else
- flow_ctrl_reduce(dev, &dev->wd_file_ext);
-
- dev->wd_pending = 0;
- } else
- dev->wd_pending = 1;
-
- dev->wd_stoped = 0;
-
- err = 0;
- while (!dev->wd_stoped && err != -1) {
- err = cv_reltimedwait(&dev->wait_stop_wd,
- &dev->device_lock, 10*HZ, TR_CLOCK_TICK);
- }
-
- if (!dev->wd_stoped) {
- DBG("stop wd failed to complete.\n");
- } else {
- DBG("stop wd complete.\n");
- }
-
- }
-
- mutex_exit(&dev->device_lock);
-
- if (dev->iamthif_file_ext.state == HECI_FILE_CONNECTED) {
- dev->iamthif_file_ext.state = HECI_FILE_DISCONNECTING;
- (void) heci_disconnect_host_client(dev,
- &dev->iamthif_file_ext);
- }
- if (dev->wd_file_ext.state == HECI_FILE_CONNECTED) {
- dev->wd_file_ext.state = HECI_FILE_DISCONNECTING;
- (void) heci_disconnect_host_client(dev,
- &dev->wd_file_ext);
- }
-
-
- /* remove entry if already in list */
- DBG("list del iamthif and wd file list.\n");
- heci_remove_client_from_file_list(dev, dev->wd_file_ext.
- host_client_id);
- heci_remove_client_from_file_list(dev,
- dev->iamthif_file_ext.host_client_id);
-
- dev->iamthif_current_cb = NULL;
- dev->iamthif_file_ext.file = NULL;
-
- /* disable interrupts */
- heci_csr_disable_interrupts(dev);
-
- ddi_remove_intr(dip, 0, dev->sc_iblk);
-
- if (dev->work)
- ddi_taskq_destroy(dev->work);
- if (dev->reinit_tsk)
- ddi_taskq_destroy(dev->reinit_tsk);
- if (dev->mem_addr)
- ddi_regs_map_free(&dev->io_handle);
-
- if (dev->me_clients && dev->num_heci_me_clients > 0) {
- kmem_free(dev->me_clients, sizeof (struct heci_me_client) *
- dev->num_heci_me_clients);
- }
-
- dev->num_heci_me_clients = 0;
-
- heci_destroy_locks(dev);
-
- ddi_remove_minor_node(dip, NULL);
- ddi_soft_state_free(heci_soft_state_p, ddi_get_instance(dip));
-
- return (DDI_SUCCESS);
-}
-
-
-static int
-heci_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
-{
- int error = DDI_SUCCESS;
- struct iamt_heci_device *device;
- int minor, instance;
-
- _NOTE(ARGUNUSED(dip))
-
- switch (cmd) {
- case DDI_INFO_DEVT2DEVINFO:
- minor = getminor((dev_t)arg);
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if (!(device = ddi_get_soft_state(heci_soft_state_p, instance)))
- *result = NULL;
- else
- *result = device->dip;
- break;
- case DDI_INFO_DEVT2INSTANCE:
- minor = getminor((dev_t)arg);
- instance = HECI_MINOR_TO_INSTANCE(minor);
- *result = (void *)((long)minor);
- break;
- default:
- error = DDI_FAILURE;
- break;
- }
- return (error);
-}
-/*
- * heci_clear_list - remove all callbacks associated with file
- * from heci_cb_list
- *
- * @file: file information struct
- * @heci_cb_list: callbacks list
- *
- * heci_clear_list is called to clear resources associated with file
- * when application calls close function or Ctrl-C was pressed
- *
- * @return 1 if callback removed from the list, 0 otherwise
- */
-static int
-heci_clear_list(struct iamt_heci_device *dev,
- struct heci_file *file, struct list_node *heci_cb_list)
-{
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
- struct heci_file *file_temp;
- int rets = 0;
-
- /* list all list member */
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- heci_cb_list, cb_list, struct heci_cb_private) {
- file_temp = (struct heci_file *)priv_cb_pos->file_object;
- /* check if list member associated with a file */
- if (file_temp == file) {
- /* remove member from the list */
- list_del(&priv_cb_pos->cb_list);
- /* check if cb equal to current iamthif cb */
- if (dev->iamthif_current_cb == priv_cb_pos) {
- dev->iamthif_current_cb = NULL;
- /* send flow control to iamthif client */
- if (!heci_send_flow_control(dev,
- &dev->iamthif_file_ext)) {
- DBG("sending flow control failed\n");
- }
- }
- /* free all allocated buffers */
- heci_free_cb_private(priv_cb_pos);
- rets = 1;
- }
- }
- return (rets);
-}
-
-/*
- * heci_clear_lists - remove all callbacks associated with file
- *
- * @dev: device information struct
- * @file: file information struct
- *
- * heci_clear_lists is called to clear resources associated with file
- * when application calls close function or Ctrl-C was pressed
- *
- * @return 1 if callback removed from the list, 0 otherwise
- */
-static int
-heci_clear_lists(struct iamt_heci_device *dev, struct heci_file *file)
-{
- int rets = 0;
-
- /* remove callbacks associated with a file */
- (void) heci_clear_list(dev, file, &dev->pthi_cmd_list.heci_cb.cb_list);
- if (heci_clear_list(dev, file,
- &dev->pthi_read_complete_list.heci_cb.cb_list))
- rets = 1;
-
- (void) heci_clear_list(dev, file, &dev->ctrl_rd_list.heci_cb.cb_list);
-
- if (heci_clear_list(dev, file, &dev->ctrl_wr_list.heci_cb.cb_list))
- rets = 1;
-
- if (heci_clear_list(dev, file,
- &dev->write_waiting_list.heci_cb.cb_list))
- rets = 1;
-
- if (heci_clear_list(dev, file, &dev->write_list.heci_cb.cb_list))
- rets = 1;
-
- /* check if iamthif_current_cb not NULL */
- if (dev->iamthif_current_cb && (!rets)) {
- /* check file and iamthif current cb association */
- if (dev->iamthif_current_cb->file_object == file) {
- /* remove cb */
- heci_free_cb_private(dev->iamthif_current_cb);
- dev->iamthif_current_cb = NULL;
- rets = 1;
- }
- }
- return (rets);
-}
-
-/*
- * heci_open - the open function
- */
-static int
-heci_open(dev_t *devp, int flags, int otyp, cred_t *credp)
-{
- struct iamt_heci_device *dev;
- struct heci_file_private *file_ext = NULL;
- int minor, if_num, instance;
- struct heci_file *file;
-
- _NOTE(ARGUNUSED(flags, credp))
-
- minor = getminor(*devp);
-
- DBG("heci_open: enter...\n");
-
- /*
- * Make sure the open is for the right file type.
- */
- if (otyp != OTYP_CHR)
- return (EINVAL);
-
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- dev = ddi_get_soft_state(heci_soft_state_p, instance);
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev))
- return (-ENODEV);
-
- file_ext = heci_alloc_file_private(NULL);
- if (file_ext == NULL)
- return (-ENOMEM);
-
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- kmem_free(file_ext, sizeof (struct heci_file_private));
- file_ext = NULL;
- return (-ENODEV);
- }
- if (dev->open_handle_count >= HECI_MAX_OPEN_HANDLE_COUNT) {
- mutex_exit(&dev->device_lock);
- kmem_free(file_ext, sizeof (struct heci_file_private));
- file_ext = NULL;
- return (-ENFILE);
- }
- dev->open_handle_count++;
- list_add_tail(&file_ext->link, &dev->file_list);
- while ((dev->heci_host_clients[dev->current_host_client_id / 8]
- & (1 << (dev->current_host_client_id % 8))) != 0) {
-
- dev->current_host_client_id++;
- dev->current_host_client_id %= HECI_MAX_OPEN_HANDLE_COUNT;
- DBG("current_host_client_id = %d\n",
- dev->current_host_client_id);
- DBG("dev->open_handle_count = %lu\n",
- dev->open_handle_count);
- }
- DBG("current_host_client_id = %d\n", dev->current_host_client_id);
- file_ext->host_client_id = dev->current_host_client_id;
- *devp = makedevice(getmajor(*devp),
- MAKE_MINOR_NUM(dev->current_host_client_id, instance));
- file = &dev->files[dev->current_host_client_id];
- dev->heci_host_clients[file_ext->host_client_id / 8] |=
- (1 << (file_ext->host_client_id % 8));
- mutex_exit(&dev->device_lock);
- mutex_enter(&file_ext->file_lock);
- file_ext->state = HECI_FILE_INITIALIZING;
- file_ext->sm_state = 0;
-
- file->private_data = file_ext;
- mutex_exit(&file_ext->file_lock);
-
- return (0);
-}
-
-/*
- * heci_close - the close function
- */
-static int
-heci_close(dev_t devt, int flag, int otyp, struct cred *cred)
-{
- int rets = 0;
- int minor, if_num, instance;
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb = NULL;
- struct iamt_heci_device *dev;
- struct heci_file *file;
-
- _NOTE(ARGUNUSED(flag, otyp, cred))
-
- minor = getminor(devt);
-
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- dev = ddi_get_soft_state(heci_soft_state_p, instance);
-
- file = &dev->files[if_num];
- file_ext = file->private_data;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file_ext))
- return (-ENODEV);
-
- if (file_ext != &dev->iamthif_file_ext) {
- mutex_enter(&file_ext->file_lock);
- if (file_ext->state == HECI_FILE_CONNECTED) {
- file_ext->state = HECI_FILE_DISCONNECTING;
- mutex_exit(&file_ext->file_lock);
- DBG("disconnecting client host client = %d, "
- "ME client = %d\n",
- file_ext->host_client_id,
- file_ext->me_client_id);
- rets = heci_disconnect_host_client(dev, file_ext);
- mutex_enter(&file_ext->file_lock);
- }
- mutex_enter(&dev->device_lock);
- heci_flush_queues(dev, file_ext);
- DBG("remove client host client = %d, ME client = %d\n",
- file_ext->host_client_id,
- file_ext->me_client_id);
-
- if (dev->open_handle_count > 0) {
- dev->heci_host_clients[file_ext->host_client_id / 8] &=
- ~(1 << (file_ext->host_client_id % 8));
- dev->open_handle_count--;
- }
- heci_remove_client_from_file_list(dev,
- file_ext->host_client_id);
-
- /* free read cb */
- if (file_ext->read_cb != NULL) {
- priv_cb = find_read_list_entry(dev, file_ext);
- /* Remove entry from read list */
- if (priv_cb != NULL)
- list_del(&priv_cb->cb_list);
-
- priv_cb = file_ext->read_cb;
- file_ext->read_cb = NULL;
- }
-
- mutex_exit(&dev->device_lock);
- file->private_data = NULL;
- mutex_exit(&file_ext->file_lock);
-
- if (priv_cb != NULL)
- heci_free_cb_private(priv_cb);
-
- heci_free_file_private(file_ext);
- } else {
- mutex_enter(&dev->device_lock);
-
- if (dev->open_handle_count > 0)
- dev->open_handle_count--;
-
- if (dev->iamthif_file_object == file &&
- dev->iamthif_state != HECI_IAMTHIF_IDLE) {
- DBG("pthi canceled iamthif state %d\n",
- dev->iamthif_state);
- dev->iamthif_canceled = 1;
- if (dev->iamthif_state == HECI_IAMTHIF_READ_COMPLETE) {
- DBG("run next pthi iamthif cb\n");
- run_next_iamthif_cmd(dev);
- }
- }
-
- if (heci_clear_lists(dev, file))
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
-
- mutex_exit(&dev->device_lock);
- }
- return (rets);
-}
-
-static struct heci_cb_private *
-find_read_list_entry(struct iamt_heci_device *dev,
- struct heci_file_private *file_ext)
-{
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
- struct heci_file_private *file_ext_list_temp;
-
- if (dev->read_list.status == 0 &&
- !list_empty(&dev->read_list.heci_cb.cb_list)) {
-
- DBG("remove read_list CB \n");
- list_for_each_entry_safe(priv_cb_pos,
- priv_cb_next,
- &dev->read_list.heci_cb.cb_list, cb_list,
- struct heci_cb_private) {
-
- file_ext_list_temp = (struct heci_file_private *)
- priv_cb_pos->file_private;
-
- if ((file_ext_list_temp != NULL) &&
- heci_fe_same_id(file_ext, file_ext_list_temp))
- return (priv_cb_pos);
-
- }
- }
- return (NULL);
-}
-
-/*
- * heci_read - the read client message function.
- */
-static int
-heci_read(dev_t devt, struct uio *uio_p, cred_t *cred_p)
-{
- int i;
- int rets = 0;
- size_t length;
- struct heci_file *file;
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_cb_pos = NULL;
- int instance, minor, if_num, err;
- struct heci_cb_private *priv_cb = NULL;
- struct iamt_heci_device *dev;
-
- _NOTE(ARGUNUSED(cred_p))
-
- minor = getminor(devt);
-
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- dev = ddi_get_soft_state(heci_soft_state_p, instance);
-
- file = &dev->files[if_num];
- file_ext = file->private_data;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file_ext))
- return (-ENODEV);
-
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- mutex_exit(&dev->device_lock);
- if (!file_ext)
- return (-ENODEV);
-
- mutex_enter(&file_ext->file_lock);
- if ((file_ext->sm_state & HECI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
- mutex_exit(&file_ext->file_lock);
- /* Do not allow to read watchdog client */
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (memcmp(&heci_wd_guid,
- &dev->me_clients[i].props.protocol_name,
- sizeof (struct guid)) == 0) {
- if (file_ext->me_client_id ==
- dev->me_clients[i].client_id)
- return (-EBADF);
- }
- }
- } else {
- file_ext->sm_state &= ~HECI_WD_STATE_INDEPENDENCE_MSG_SENT;
- mutex_exit(&file_ext->file_lock);
- }
-
- if (file_ext == &dev->iamthif_file_ext) {
- rets = pthi_read(dev, if_num, file, uio_p);
- goto out;
- }
-
- if (file_ext->read_cb &&
- file_ext->read_cb->information > UIO_OFFSET(uio_p)) {
- priv_cb = file_ext->read_cb;
- goto copy_buffer;
- } else if (file_ext->read_cb && file_ext->read_cb->information > 0 &&
- file_ext->read_cb->information <= UIO_OFFSET(uio_p)) {
- priv_cb = file_ext->read_cb;
- rets = 0;
- goto free;
- } else if (
- (!file_ext->read_cb || file_ext->read_cb->information == 0) &&
- UIO_OFFSET(uio_p) > 0) {
- /* Offset needs to be cleaned for contingous reads */
- UIO_OFFSET(uio_p) = 0;
- rets = 0;
- goto out;
- }
-
- mutex_enter(&file_ext->read_io_lock);
- err = heci_start_read(dev, if_num, file_ext);
- if (err != 0 && err != -EBUSY) {
- DBG("heci start read failure with status = %d\n", err);
- mutex_exit(&file_ext->read_io_lock);
- rets = err;
- goto out;
- }
- while (HECI_READ_COMPLETE != file_ext->reading_state &&
- HECI_FILE_INITIALIZING != file_ext->state &&
- HECI_FILE_DISCONNECTED != file_ext->state &&
- HECI_FILE_DISCONNECTING != file_ext->state) {
- mutex_exit(&file_ext->read_io_lock);
- mutex_enter(&dev->device_lock);
- if (cv_wait_sig(&file_ext->rx_wait, &dev->device_lock) == 0) {
- mutex_exit(&dev->device_lock);
- priv_cb = file_ext->read_cb;
- rets = -EINTR;
- goto free;
- }
- mutex_exit(&dev->device_lock);
-
-
- if (HECI_FILE_INITIALIZING == file_ext->state ||
- HECI_FILE_DISCONNECTED == file_ext->state ||
- HECI_FILE_DISCONNECTING == file_ext->state) {
- rets = -EBUSY;
- goto out;
- }
- mutex_enter(&file_ext->read_io_lock);
- }
-
- priv_cb = file_ext->read_cb;
-
- if (!priv_cb) {
- mutex_exit(&file_ext->read_io_lock);
- return (-ENODEV);
- }
- if (file_ext->reading_state != HECI_READ_COMPLETE) {
- mutex_exit(&file_ext->read_io_lock);
- return (0);
- }
- mutex_exit(&file_ext->read_io_lock);
- /* now copy the data to user space */
-copy_buffer:
- DBG("priv_cb->response_buffer size - %d\n",
- priv_cb->response_buffer.size);
- DBG("priv_cb->information - %lu\n", priv_cb->information);
- if (uio_p->uio_resid == 0 || uio_p->uio_resid < priv_cb->information) {
- rets = -EMSGSIZE;
- goto free;
- }
- length = (uio_p->uio_resid <
- (priv_cb->information - uio_p->uio_offset) ?
- uio_p->uio_resid : (priv_cb->information - uio_p->uio_offset));
-
- if (uiomove(priv_cb->response_buffer.data,
- length, UIO_READ, uio_p)) {
- rets = -EFAULT;
- goto free;
- }
- else
- rets = 0;
-
-free:
- mutex_enter(&dev->device_lock);
- priv_cb_pos = find_read_list_entry(dev, file_ext);
- /* Remove entry from read list */
- if (priv_cb_pos != NULL)
- list_del(&priv_cb_pos->cb_list);
- mutex_exit(&dev->device_lock);
- heci_free_cb_private(priv_cb);
- mutex_enter(&file_ext->read_io_lock);
- file_ext->reading_state = HECI_IDLE;
- file_ext->read_cb = NULL;
- file_ext->read_pending = 0;
- mutex_exit(&file_ext->read_io_lock);
-out: DBG("end heci read rets= %d\n", rets);
- return (rets);
-}
-
-/*
- * heci_write - the write function.
- */
-static int
-heci_write(dev_t devt, struct uio *uio_p, struct cred *cred)
-{
- int rets = 0;
- uint8_t i;
- size_t length;
- struct heci_file_private *file_ext;
- struct heci_cb_private *priv_write_cb = NULL;
- struct heci_msg_hdr heci_hdr;
- struct iamt_heci_device *dev;
- unsigned long currtime = ddi_get_time();
- int instance, minor, if_num, err;
- struct heci_file *file;
-
- _NOTE(ARGUNUSED(cred))
- DBG("heci_write enter...\n");
-
- minor = getminor(devt);
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- dev = ddi_get_soft_state(heci_soft_state_p, instance);
-
- file = &dev->files[if_num];
- file_ext = file->private_data;
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file_ext))
- return (-ENODEV);
-
- mutex_enter(&dev->device_lock);
-
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- if (file_ext == &dev->iamthif_file_ext) {
- priv_write_cb = find_pthi_read_list_entry(dev, file);
- if ((priv_write_cb != NULL) &&
- (((currtime - priv_write_cb->read_time) >
- IAMTHIF_READ_TIMER) ||
- (file_ext->reading_state == HECI_READ_COMPLETE))) {
- UIO_OFFSET(uio_p) = 0;
- list_del(&priv_write_cb->cb_list);
- heci_free_cb_private(priv_write_cb);
- priv_write_cb = NULL;
- }
- }
-
- /* free entry used in read */
- if (file_ext->reading_state == HECI_READ_COMPLETE) {
- UIO_OFFSET(uio_p) = 0;
- priv_write_cb = find_read_list_entry(dev, file_ext);
- if (priv_write_cb != NULL) {
- list_del(&priv_write_cb->cb_list);
- heci_free_cb_private(priv_write_cb);
- priv_write_cb = NULL;
- mutex_enter(&file_ext->read_io_lock);
- file_ext->reading_state = HECI_IDLE;
- file_ext->read_cb = NULL;
- file_ext->read_pending = 0;
- mutex_exit(&file_ext->read_io_lock);
- }
- } else if (file_ext->reading_state == HECI_IDLE &&
- file_ext->read_pending == 0)
- UIO_OFFSET(uio_p) = 0;
-
- mutex_exit(&dev->device_lock);
-
- priv_write_cb = kmem_zalloc(sizeof (struct heci_cb_private), KM_SLEEP);
- if (!priv_write_cb)
- return (-ENOMEM);
-
- priv_write_cb->file_object = file;
- priv_write_cb->file_private = file_ext;
- priv_write_cb->request_buffer.data =
- kmem_zalloc(uio_p->uio_resid, KM_SLEEP);
- if (!priv_write_cb->request_buffer.data) {
- kmem_free(priv_write_cb, sizeof (struct heci_cb_private));
- return (-ENOMEM);
- }
- length = (int)uio_p->uio_resid;
- DBG("length =%d\n", (int)length);
-
- err = uiomove(priv_write_cb->request_buffer.data,
- length, UIO_WRITE, uio_p);
- if (err) {
- rets = err;
- goto fail;
- }
-
-#define UBUFF UIO_BUFF(uio_p)
-
- mutex_enter(&file_ext->file_lock);
- file_ext->sm_state = 0;
- if ((length == 4) &&
- ((memcmp(heci_wd_state_independence_msg[0], UBUFF, 4) == 0) ||
- (memcmp(heci_wd_state_independence_msg[1], UBUFF, 4) == 0) ||
- (memcmp(heci_wd_state_independence_msg[2], UBUFF, 4) == 0)))
-
- file_ext->sm_state |= HECI_WD_STATE_INDEPENDENCE_MSG_SENT;
-
- mutex_exit(&file_ext->file_lock);
-
- LIST_INIT_HEAD(&priv_write_cb->cb_list);
- if (file_ext == &dev->iamthif_file_ext) {
- priv_write_cb->response_buffer.data =
- kmem_zalloc(IAMTHIF_MTU, KM_SLEEP);
- if (!priv_write_cb->response_buffer.data) {
- rets = -ENOMEM;
- goto fail;
- }
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- rets = -ENODEV;
- goto fail;
- }
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id ==
- dev->iamthif_file_ext.me_client_id)
- break;
- }
-
- ASSERT(dev->me_clients[i].client_id == file_ext->me_client_id);
- if ((i == dev->num_heci_me_clients) ||
- (dev->me_clients[i].client_id !=
- dev->iamthif_file_ext.me_client_id)) {
-
- mutex_exit(&dev->device_lock);
- rets = -ENODEV;
- goto fail;
- } else if ((length >
- dev->me_clients[i].props.max_msg_length) ||
- (length == 0)) {
- mutex_exit(&dev->device_lock);
- rets = -EMSGSIZE;
- goto fail;
- }
-
-
- priv_write_cb->response_buffer.size = IAMTHIF_MTU;
- priv_write_cb->major_file_operations = HECI_IOCTL;
- priv_write_cb->information = 0;
- priv_write_cb->request_buffer.size = (uint32_t)length;
- if (dev->iamthif_file_ext.state != HECI_FILE_CONNECTED) {
- mutex_exit(&dev->device_lock);
- rets = -ENODEV;
- goto fail;
- }
-
- if (!list_empty(&dev->pthi_cmd_list.heci_cb.cb_list) ||
- dev->iamthif_state != HECI_IAMTHIF_IDLE) {
- DBG("pthi_state = %d\n", (int)dev->iamthif_state);
- DBG("add PTHI cb to pthi cmd waiting list\n");
- list_add_tail(&priv_write_cb->cb_list,
- &dev->pthi_cmd_list.heci_cb.cb_list);
- rets = 0; /* length; */
- } else {
- DBG("call pthi write\n");
- rets = pthi_write(dev, priv_write_cb);
-
- if (rets != 0) {
- DBG("pthi write failed with status = %d\n",
- rets);
- mutex_exit(&dev->device_lock);
- goto fail;
- }
- rets = 0; /* length; */
- }
- mutex_exit(&dev->device_lock);
- return (rets);
- }
-
- priv_write_cb->major_file_operations = HECI_WRITE;
- /* make sure information is zero before we start */
-
- priv_write_cb->information = 0;
- priv_write_cb->request_buffer.size = (uint32_t)length;
-
- mutex_enter(&dev->device_lock);
- mutex_enter(&file_ext->write_io_lock);
- DBG("host client = %d, ME client = %d\n",
- file_ext->host_client_id, file_ext->me_client_id);
- if (file_ext->state != HECI_FILE_CONNECTED) {
- rets = -ENODEV;
- DBG("host client = %d, is not connected to ME client = %d",
- file_ext->host_client_id,
- file_ext->me_client_id);
-
- goto unlock;
- }
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id ==
- file_ext->me_client_id)
- break;
- }
- ASSERT(dev->me_clients[i].client_id == file_ext->me_client_id);
- if (i == dev->num_heci_me_clients) {
- rets = -ENODEV;
- goto unlock;
- }
- if (length > dev->me_clients[i].props.max_msg_length || length == 0) {
- rets = -EINVAL;
- goto unlock;
- }
- priv_write_cb->file_private = file_ext;
-
- if (flow_ctrl_creds(dev, file_ext) &&
- dev->host_buffer_is_empty) {
- dev->host_buffer_is_empty = 0;
- if (length > ((((dev->host_hw_state & H_CBD) >> 24) *
- sizeof (uint32_t)) - sizeof (struct heci_msg_hdr))) {
-
- heci_hdr.length =
- (((dev->host_hw_state & H_CBD) >> 24) *
- sizeof (uint32_t)) -
- sizeof (struct heci_msg_hdr);
- heci_hdr.msg_complete = 0;
- } else {
- heci_hdr.length = (uint32_t)length;
- heci_hdr.msg_complete = 1;
- }
- heci_hdr.host_addr = file_ext->host_client_id;
- heci_hdr.me_addr = file_ext->me_client_id;
- heci_hdr.reserved = 0;
- DBG("call heci_write_message header=%08x.\n",
- *((uint32_t *)(void *)&heci_hdr));
- /* protect heci low level write */
- if (!heci_write_message(dev, &heci_hdr,
- (unsigned char *)(priv_write_cb->request_buffer.data),
- heci_hdr.length)) {
-
- mutex_exit(&file_ext->write_io_lock);
- mutex_exit(&dev->device_lock);
- heci_free_cb_private(priv_write_cb);
- rets = -ENODEV;
- priv_write_cb->information = 0;
- return (rets);
- }
- file_ext->writing_state = HECI_WRITING;
- priv_write_cb->information = heci_hdr.length;
- if (heci_hdr.msg_complete) {
- flow_ctrl_reduce(dev, file_ext);
- list_add_tail(&priv_write_cb->cb_list,
- &dev->write_waiting_list.heci_cb.cb_list);
- } else {
- list_add_tail(&priv_write_cb->cb_list,
- &dev->write_list.heci_cb.cb_list);
- }
-
- } else {
-
- priv_write_cb->information = 0;
- file_ext->writing_state = HECI_WRITING;
- list_add_tail(&priv_write_cb->cb_list,
- &dev->write_list.heci_cb.cb_list);
- }
- mutex_exit(&file_ext->write_io_lock);
- mutex_exit(&dev->device_lock);
- return (0);
-
-unlock:
- mutex_exit(&file_ext->write_io_lock);
- mutex_exit(&dev->device_lock);
-fail:
- heci_free_cb_private(priv_write_cb);
- return (rets);
-
-}
-
-/*
- * heci_ioctl - the IOCTL function
- */
-static int
-heci_ioctl(dev_t devt, int cmd, intptr_t arg, int mode, cred_t *cr, int *rval)
-{
- int rets = 0;
- struct heci_file_private *file_ext;
- /* in user space */
- struct heci_message_data *u_msg = (struct heci_message_data *)arg;
- struct heci_message_data k_msg; /* all in kernel on the stack */
- struct iamt_heci_device *dev;
- int instance, minor, if_num;
- struct heci_file *file;
-
- _NOTE(ARGUNUSED(cr, rval))
-
- minor = getminor(devt);
-
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- dev = ddi_get_soft_state(heci_soft_state_p, instance);
-
- file = &dev->files[if_num];
- file_ext = file->private_data;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file_ext))
- return (-ENODEV);
-
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- mutex_exit(&dev->device_lock);
-
- /* first copy from user all data needed */
- if (ddi_copyin(u_msg, &k_msg, sizeof (k_msg), mode)) {
- DBG("first copy from user all data needed filled\n");
- return (-EFAULT);
- }
-#ifdef _LP64
- if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) {
- uint32_t addr32 = (uint32_t)(uint64_t)k_msg.data;
- k_msg.data = (char *)(uint64_t)addr32;
- DBG("IPL32: k_msg.data=%p\n", (void *)k_msg.data);
- }
-#endif
- DBG("user message size is %d, cmd = 0x%x\n", k_msg.size, cmd);
-
- switch (cmd) {
- case IOCTL_HECI_GET_VERSION:
- DBG(": IOCTL_HECI_GET_VERSION\n");
- rets = heci_ioctl_get_version(dev, if_num, u_msg, k_msg,
- file_ext, mode);
- break;
-
- case IOCTL_HECI_CONNECT_CLIENT:
- DBG(": IOCTL_HECI_CONNECT_CLIENT.\n");
- rets = heci_ioctl_connect_client(dev, if_num, u_msg, k_msg,
- file, mode);
- break;
-
- case IOCTL_HECI_WD:
- DBG(": IOCTL_HECI_WD.\n");
- rets = heci_ioctl_wd(dev, if_num, k_msg, file_ext, mode);
- break;
-
- case IOCTL_HECI_BYPASS_WD:
- DBG(": IOCTL_HECI_BYPASS_WD.\n");
- rets = heci_ioctl_bypass_wd(dev, if_num, k_msg, file_ext, mode);
- break;
-
- default:
- rets = -EINVAL;
- break;
- }
- return (rets);
-}
-
-/*
- * heci_poll - the poll function
- */
-static int
-heci_poll(dev_t devt, short events, int anyyet,
- short *reventsp, struct pollhead **phpp)
-{
- struct heci_file *file;
- struct heci_file_private *file_extension;
- struct iamt_heci_device *device = NULL;
- int instance, minor, if_num;
-
- _NOTE(ARGUNUSED(events))
-
- minor = getminor(devt);
-
- instance = HECI_MINOR_TO_INSTANCE(minor);
- if_num = HECI_MINOR_TO_IFNUM(minor);
-
- device = ddi_get_soft_state(heci_soft_state_p, instance);
-
- file = &device->files[if_num];
- file_extension = file->private_data;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!device) || (!file_extension))
- return (-ENODEV);
-
- mutex_enter(&device->device_lock);
- if (device->heci_state != HECI_ENABLED) {
- mutex_exit(&device->device_lock);
- return (-ENXIO);
-
- }
-
- mutex_exit(&device->device_lock);
-
- if (file_extension == &device->iamthif_file_ext) {
-
- mutex_enter(&device->iamthif_file_ext.file_lock);
-
- if (device->iamthif_state == HECI_IAMTHIF_READ_COMPLETE &&
- device->iamthif_file_object == file) {
- *reventsp |= (POLLIN | POLLRDNORM);
- mutex_enter(&device->device_lock);
- DBG("heci_poll: run next pthi cb\n");
- run_next_iamthif_cmd(device);
- mutex_exit(&device->device_lock);
- } else {
- DBG("heci_poll: iamthif no event\n");
- *reventsp = 0;
- if (!anyyet)
- *phpp = &device->iamthif_file_ext.pollwait;
- }
- mutex_exit(&device->iamthif_file_ext.file_lock);
-
- } else {
- mutex_enter(&file_extension->write_io_lock);
- if (HECI_WRITE_COMPLETE == file_extension->writing_state) {
- *reventsp |= (POLLIN | POLLRDNORM);
- DBG("heci_poll: file_extension poll event\n");
- } else {
- DBG("heci_poll: file_extension no event\n");
- *reventsp = 0;
- if (!anyyet)
- *phpp = &file_extension->tx_pollwait;
- }
- mutex_exit(&file_extension->write_io_lock);
-
-
- }
-
- return (0);
-}
-
-/*
- * heci_fe_same_id - tell if file private data have same id
- *
- * @fe1: private data of 1. file object
- * @fe2: private data of 2. file object
- *
- * @return !=0 - if ids are the same, 0 - if differ.
- */
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2)
-{
- return ((fe1->host_client_id == fe2->host_client_id) &&
- (fe1->me_client_id == fe2->me_client_id));
-}
-
-/*
- * Since the ME firmware won't reset itself during OS reboot, it's not enough
- * to only disable interrupts in quiesce(), here we do a full hand-shake
- * with the firmware.
- */
-static int
-heci_quiesce(dev_info_t *dip)
-{
- struct iamt_heci_device *dev;
-
- dev = ddi_get_soft_state(heci_soft_state_p, ddi_get_instance(dip));
- ASSERT(dev != NULL);
-
- if (dev->wd_file_ext.state == HECI_FILE_CONNECTED &&
- dev->wd_timeout) {
- dev->wd_timeout = 0;
- dev->wd_due_counter = 0;
- (void) memcpy(dev->wd_data, stop_wd_params,
- HECI_WD_PARAMS_SIZE);
- if (!heci_send_wd(dev)) {
- DBG("send stop WD failed\n");
- }
-
- }
-
- /* disable interrupts */
- heci_csr_disable_interrupts(dev);
-
- return (DDI_SUCCESS);
-}
-
-static int
-heci_suspend(dev_info_t *dip)
-{
- struct iamt_heci_device *device;
- int err = 0;
-
- device = ddi_get_soft_state(heci_soft_state_p, ddi_get_instance(dip));
-
- if (device->reinit_tsk)
- ddi_taskq_wait(device->reinit_tsk);
-
- /* Stop watchdog if exists */
- if (device->wd_timer)
- (void) untimeout(device->wd_timer);
-
- mutex_enter(&device->device_lock);
-
- if (device->wd_file_ext.state == HECI_FILE_CONNECTED &&
- device->wd_timeout) {
- g_sus_wd_timeout = device->wd_timeout;
- device->wd_timeout = 0;
- device->wd_due_counter = 0;
- (void) memcpy(device->wd_data, stop_wd_params,
- HECI_WD_PARAMS_SIZE);
- device->stop = 1;
- if (device->host_buffer_is_empty &&
- flow_ctrl_creds(device, &device->wd_file_ext)) {
- device->host_buffer_is_empty = 0;
- if (!heci_send_wd(device)) {
- DBG("send stop WD failed\n");
- }
- else
- flow_ctrl_reduce(device, &device->wd_file_ext);
-
- device->wd_pending = 0;
- } else {
- device->wd_pending = 1;
- }
- device->wd_stoped = 0;
-
- err = 0;
- while (!device->wd_stoped && err != -1) {
- err = cv_reltimedwait(&device->wait_stop_wd,
- &device->device_lock, 10*HZ, TR_CLOCK_TICK);
- }
-
- if (!device->wd_stoped) {
- DBG("stop wd failed to complete.\n");
- } else {
- DBG("stop wd complete %d.\n", err);
- err = 0;
- }
- }
- /* Set new heci state */
- if (device->heci_state == HECI_ENABLED ||
- device->heci_state == HECI_RECOVERING_FROM_RESET) {
- device->heci_state = HECI_POWER_DOWN;
- heci_reset(device, 0);
- }
-
- /* Here interrupts are already disabled by heci_reset() */
-
- mutex_exit(&device->device_lock);
-
-
- return (err);
-}
-
-static void
-heci_resume(dev_info_t *dip)
-{
- struct iamt_heci_device *device;
-
- device = ddi_get_soft_state(heci_soft_state_p, ddi_get_instance(dip));
-
- mutex_enter(&device->device_lock);
- device->heci_state = HECI_POWER_UP;
- heci_reset(device, 1);
- mutex_exit(&device->device_lock);
-
- /* Start watchdog if stopped in suspend */
- if (g_sus_wd_timeout != 0) {
- device->wd_timeout = g_sus_wd_timeout;
-
- (void) memcpy(device->wd_data, start_wd_params,
- HECI_WD_PARAMS_SIZE);
- (void) memcpy(device->wd_data + HECI_WD_PARAMS_SIZE,
- &device->wd_timeout, sizeof (uint16_t));
- device->wd_due_counter = 1;
-
- if (device->wd_timeout)
- device->wd_timer = timeout(heci_wd_timer, device, 1);
-
- g_sus_wd_timeout = 0;
- }
-}
diff --git a/usr/src/uts/intel/io/heci/io_heci.c b/usr/src/uts/intel/io/heci/io_heci.c
deleted file mode 100644
index 994cde3194..0000000000
--- a/usr/src/uts/intel/io/heci/io_heci.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of Intel(R) Manageability Engine Interface Linux driver
- *
- * Copyright (c) 2003 - 2008 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#include <sys/types.h>
-#include <sys/note.h>
-#include <sys/cmn_err.h>
-#include <sys/conf.h>
-#include <sys/ddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/devops.h>
-#include <sys/instance.h>
-#include <sys/modctl.h>
-#include <sys/open.h>
-#include <sys/stat.h>
-#include <sys/sunddi.h>
-#include <sys/sunndi.h>
-#include <sys/systm.h>
-#include <sys/mkdev.h>
-#include <sys/list.h>
-#include "heci_data_structures.h"
-#include "heci.h"
-#include "heci_interface.h"
-#include "version.h"
-
-
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2);
-/*
- * heci_ioctl_get_version - the get driver version IOCTL function
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @*u_msg: pointer to user data struct in user space
- * @k_msg: data in kernel on the stack
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_ioctl_get_version(struct iamt_heci_device *dev, int if_num,
- struct heci_message_data *u_msg,
- struct heci_message_data k_msg,
- struct heci_file_private *file_ext, int mode)
-{
-
- int rets = 0;
- struct heci_driver_version *version;
- struct heci_message_data res_msg;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) ||
- (!file_ext))
- return (-ENODEV);
-
- if (k_msg.size < (sizeof (struct heci_driver_version) - 2)) {
- DBG("user buffer less than heci_driver_version.\n");
- return (-EMSGSIZE);
- }
-
- res_msg.data = kmem_zalloc(sizeof (struct heci_driver_version),
- KM_SLEEP);
- if (!res_msg.data) {
- DBG("failed allocation response buffer size = %d.\n",
- (int)sizeof (struct heci_driver_version));
- return (-ENOMEM);
- }
-
- version = (struct heci_driver_version *)res_msg.data;
- version->major = MAJOR_VERSION;
- version->minor = MINOR_VERSION;
- version->hotfix = QUICK_FIX_NUMBER;
- version->build = VER_BUILD;
- res_msg.size = sizeof (struct heci_driver_version);
- if (k_msg.size < sizeof (struct heci_driver_version))
- res_msg.size -= 2;
-
- rets = file_ext->status;
- /* now copy the data to user space */
- if (ddi_copyout(res_msg.data, k_msg.data, res_msg.size, mode)) {
- rets = -EFAULT;
- goto end;
- }
- if (ddi_copyout(&res_msg.size, &u_msg->size, sizeof (uint32_t), mode)) {
- rets = -EFAULT;
- goto end;
- }
-end:
- kmem_free(res_msg.data, sizeof (struct heci_driver_version));
- return (rets);
-}
-
-/*
- * heci_ioctl_connect_client - the connect to fw client IOCTL function
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @*u_msg: pointer to user data struct in user space
- * @k_msg: data in kernel on the stack
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_ioctl_connect_client(struct iamt_heci_device *dev, int if_num,
- struct heci_message_data *u_msg,
- struct heci_message_data k_msg,
- struct heci_file *file, int mode)
-{
-
- int rets = 0;
- struct heci_message_data req_msg, res_msg;
- struct heci_cb_private *priv_cb = NULL;
- struct heci_client *client;
- struct heci_file_private *file_ext;
- struct heci_file_private *file_pos = NULL;
- struct heci_file_private *file_next = NULL;
- long timeout = 15; /* 15 second */
- uint8_t i;
- int err = 0;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file))
- return (-ENODEV);
-
- file_ext = file->private_data;
- if (!file_ext)
- return (-ENODEV);
-
- if (k_msg.size != sizeof (struct guid)) {
- DBG("user buffer size is not equal to size of struct "
- "guid(16).\n");
- return (-EMSGSIZE);
- }
-
- if (!k_msg.data)
- return (-EIO);
-
- req_msg.data = kmem_zalloc(sizeof (struct guid), KM_SLEEP);
- res_msg.data = kmem_zalloc(sizeof (struct heci_client), KM_SLEEP);
-
- if (!res_msg.data) {
- DBG("failed allocation response buffer size = %d.\n",
- (int)sizeof (struct heci_client));
- kmem_free(req_msg.data, sizeof (struct guid));
- return (-ENOMEM);
- }
- if (!req_msg.data) {
- DBG("failed allocation request buffer size = %d.\n",
- (int)sizeof (struct guid));
- if (res_msg.data) {
- kmem_free(res_msg.data, sizeof (struct heci_client));
- res_msg.data = NULL;
- goto fail;
- }
-fail:
- return (-ENOMEM);
- }
- req_msg.size = sizeof (struct guid);
- res_msg.size = sizeof (struct heci_client);
-
- /*
- * copy the message to kernel space -
- * use a pointer already copied into kernel space
- */
- if (ddi_copyin(k_msg.data, req_msg.data, k_msg.size, mode)) {
- rets = -EFAULT;
- goto end;
- }
- /* buffered ioctl cb */
- priv_cb = kmem_zalloc(sizeof (struct heci_cb_private), KM_SLEEP);
- if (!priv_cb) {
- rets = -ENOMEM;
- goto end;
- }
- LIST_INIT_HEAD(&priv_cb->cb_list);
- priv_cb->response_buffer.data = res_msg.data;
- priv_cb->response_buffer.size = res_msg.size;
- priv_cb->request_buffer.data = req_msg.data;
- priv_cb->request_buffer.size = req_msg.size;
- priv_cb->major_file_operations = HECI_IOCTL;
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- rets = -ENODEV;
- mutex_exit(&dev->device_lock);
- goto end;
- }
- if ((file_ext->state != HECI_FILE_INITIALIZING) &&
- (file_ext->state != HECI_FILE_DISCONNECTED)) {
- rets = -EBUSY;
- mutex_exit(&dev->device_lock);
- goto end;
- }
-
- DBG("req_msg.data:%x", *(uint32_t *)(void *)req_msg.data);
- /* find ME client we're trying to connect to */
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- DBG("guid:%x, me_client_id:%d\n",
- dev->me_clients[i].props.protocol_name.data1,
- dev->me_clients[i].client_id);
- if (memcmp((struct guid *)req_msg.data,
- &dev->me_clients[i].props.protocol_name,
- sizeof (struct guid)) == 0) {
- if (dev->me_clients[i].props.fixed_address == 0) {
- file_ext->me_client_id =
- dev->me_clients[i].client_id;
- file_ext->state = HECI_FILE_CONNECTING;
- }
- break;
- }
- }
- /*
- * if we're connecting to PTHI client so we will use the exist
- * connection
- */
- if (memcmp((struct guid *)req_msg.data, &heci_pthi_guid,
- sizeof (struct guid)) == 0) {
- if (dev->iamthif_file_ext.state != HECI_FILE_CONNECTED) {
- rets = -ENODEV;
- mutex_exit(&dev->device_lock);
- goto end;
- }
- dev->heci_host_clients[file_ext->host_client_id / 8] &=
- ~(1 << (file_ext->host_client_id % 8));
- list_for_each_entry_safe(file_pos,
- file_next, &dev->file_list, link,
- struct heci_file_private) {
- if (heci_fe_same_id(file_ext, file_pos)) {
- DBG("remove file private data node host"
- " client = %d, ME client = %d.\n",
- file_pos->host_client_id,
- file_pos->me_client_id);
- list_del(&file_pos->link);
- }
-
- }
- DBG("free file private data memory.\n");
- kmem_free(file_ext, sizeof (struct heci_file_private));
- file_ext = NULL;
- file->private_data = &dev->iamthif_file_ext;
- client = (struct heci_client *)res_msg.data;
- client->max_message_length =
- dev->me_clients[i].props.max_msg_length;
- client->protocol_version =
- dev->me_clients[i].props.protocol_version;
- rets = dev->iamthif_file_ext.status;
- mutex_exit(&dev->device_lock);
-
- /* now copy the data to user space */
- if (ddi_copyout(res_msg.data, k_msg.data, res_msg.size, mode)) {
- cmn_err(CE_WARN, "ddi_copyout error on res_msg.data");
- rets = -EFAULT;
- goto end;
- }
- if (ddi_copyout(&res_msg.size, &u_msg->size,
- sizeof (uint32_t), mode)) {
- cmn_err(CE_WARN, "ddi_copyout error on res_msg.size");
- rets = -EFAULT;
- goto end;
- }
- goto end;
- }
- mutex_enter(&file_ext->file_lock);
- if (file_ext->state != HECI_FILE_CONNECTING) {
- rets = -ENODEV;
- mutex_exit(&file_ext->file_lock);
- mutex_exit(&dev->device_lock);
- goto end;
- }
- mutex_exit(&file_ext->file_lock);
- /* prepare the output buffer */
- client = (struct heci_client *)res_msg.data;
- client->max_message_length = dev->me_clients[i].props.max_msg_length;
- client->protocol_version = dev->me_clients[i].props.protocol_version;
- if (dev->host_buffer_is_empty &&
- !other_client_is_connecting(dev, file_ext)) {
- dev->host_buffer_is_empty = 0;
- if (!heci_connect(dev, file_ext)) {
- rets = -ENODEV;
- mutex_exit(&dev->device_lock);
- goto end;
- } else {
- file_ext->timer_count = HECI_CONNECT_TIMEOUT;
- priv_cb->file_private = file_ext;
- list_add_tail(&priv_cb->cb_list,
- &dev->ctrl_rd_list.heci_cb.
- cb_list);
- }
-
-
- } else {
- priv_cb->file_private = file_ext;
- DBG("add connect cb to control write list.\n");
- list_add_tail(&priv_cb->cb_list,
- &dev->ctrl_wr_list.heci_cb.cb_list);
- }
- err = 0;
- while (err != -1 && HECI_FILE_CONNECTED != file_ext->state &&
- HECI_FILE_DISCONNECTED != file_ext->state) {
- err = cv_reltimedwait(&dev->wait_recvd_msg,
- &dev->device_lock, timeout * HZ, TR_CLOCK_TICK);
- }
- mutex_exit(&dev->device_lock);
-
- if (HECI_FILE_CONNECTED == file_ext->state) {
- DBG("successfully connected to FW client."
- " me_client_id:%d, host_client_id:%d\n",
- file_ext->me_client_id,
- file_ext->host_client_id);
- rets = file_ext->status;
- /* now copy the data to user space */
- if (ddi_copyout(res_msg.data, k_msg.data, res_msg.size, mode)) {
- rets = -EFAULT;
- goto end;
- }
- if (ddi_copyout(&res_msg.size, &u_msg->size,
- sizeof (uint32_t), mode)) {
- rets = -EFAULT;
- goto end;
- }
- goto end;
- } else {
- DBG("failed to connect to FW client.file_ext->state = %d,"
- " me_client_id:%d, host_client_id:%d\n",
- file_ext->state, file_ext->me_client_id,
- file_ext->host_client_id);
- if (!err) {
- DBG("wait_event_interruptible_timeout failed on client"
- " connect message fw response message.\n");
- }
- rets = -EFAULT;
- goto remove_list;
- }
-
-remove_list:
- if (priv_cb) {
- mutex_enter(&dev->device_lock);
- heci_flush_list(&dev->ctrl_rd_list, file_ext);
- heci_flush_list(&dev->ctrl_wr_list, file_ext);
- mutex_exit(&dev->device_lock);
- }
-end:
- DBG("free connect cb memory.");
- kmem_free(req_msg.data, sizeof (struct guid));
- req_msg.data = NULL;
- kmem_free(res_msg.data, sizeof (struct heci_client));
- res_msg.data = NULL;
- if (priv_cb) {
- kmem_free(priv_cb, sizeof (struct heci_cb_private));
- priv_cb = NULL;
- }
- return (rets);
-}
-
-/*
- * heci_ioctl_wd - the wd IOCTL function
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @k_msg: data in kernel on the stack
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_ioctl_wd(struct iamt_heci_device *dev, int if_num,
- struct heci_message_data k_msg,
- struct heci_file_private *file_ext, int mode)
-{
- int rets = 0;
- struct heci_message_data req_msg; /* in kernel on the stack */
-
- if (if_num < HECI_MINOR_NUMBER)
- return (-ENODEV);
-
- mutex_enter(&file_ext->file_lock);
- if (k_msg.size != HECI_WATCHDOG_DATA_SIZE) {
- DBG("user buffer has invalid size.\n");
- mutex_exit(&file_ext->file_lock);
- return (-EMSGSIZE);
- }
- mutex_exit(&file_ext->file_lock);
-
- req_msg.data = kmem_zalloc(HECI_WATCHDOG_DATA_SIZE, KM_SLEEP);
- if (!req_msg.data) {
- DBG("failed allocation request buffer size = %d.\n",
- HECI_WATCHDOG_DATA_SIZE);
- return (-ENOMEM);
- }
- req_msg.size = HECI_WATCHDOG_DATA_SIZE;
-
- /*
- * copy the message to kernel space - use a pointer already
- * copied into kernel space
- */
- if (ddi_copyin(k_msg.data, req_msg.data, k_msg.size, mode)) {
- rets = -EFAULT;
- goto end;
- }
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- rets = -ENODEV;
- mutex_exit(&dev->device_lock);
- goto end;
- }
-
- if (dev->wd_file_ext.state != HECI_FILE_CONNECTED) {
- rets = -ENODEV;
- mutex_exit(&dev->device_lock);
- goto end;
- }
- if (!dev->asf_mode) {
- rets = -EIO;
- mutex_exit(&dev->device_lock);
- goto end;
- }
-
- (void) memcpy(&dev->wd_data[HECI_WD_PARAMS_SIZE], req_msg.data,
- HECI_WATCHDOG_DATA_SIZE);
-
- dev->wd_timeout = (req_msg.data[1] << 8) + req_msg.data[0];
- dev->wd_pending = 0;
- dev->wd_due_counter = 1; /* next timer */
- if (dev->wd_timeout == 0) {
- (void) memcpy(dev->wd_data, &stop_wd_params,
- HECI_WD_PARAMS_SIZE);
- } else {
- (void) memcpy(dev->wd_data, &start_wd_params,
- HECI_WD_PARAMS_SIZE);
- dev->wd_timer = timeout(heci_wd_timer, dev, 1);
- }
- mutex_exit(&dev->device_lock);
-end:
- kmem_free(req_msg.data, HECI_WATCHDOG_DATA_SIZE);
- return (rets);
-}
-
-
-/*
- * heci_ioctl_bypass_wd - the bypass_wd IOCTL function
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @k_msg: data in kernel on the stack
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_ioctl_bypass_wd(struct iamt_heci_device *dev, int if_num,
- struct heci_message_data k_msg,
- struct heci_file_private *file_ext, int mode)
-{
- uint8_t flag = 0;
- int rets = 0;
-
- if (if_num < HECI_MINOR_NUMBER)
- return (-ENODEV);
-
- mutex_enter(&file_ext->file_lock);
- if (k_msg.size < 1) {
- DBG("user buffer less than HECI_WATCHDOG_DATA_SIZE.\n");
- mutex_exit(&file_ext->file_lock);
- return (-EMSGSIZE);
- }
- mutex_exit(&file_ext->file_lock);
- if (ddi_copyin(k_msg.data, &flag, 1, mode)) {
- rets = -EFAULT;
- goto end;
- }
-
- mutex_enter(&dev->device_lock);
- flag = flag ? (1) : (0);
- dev->wd_bypass = flag;
- mutex_exit(&dev->device_lock);
-end:
- return (rets);
-}
-
-/*
- * find_pthi_read_list_entry - finds a PTHIlist entry for current file
- *
- * @dev: Device object for our driver
- * @file: pointer to file object
- *
- * @return returned a list entry on success, NULL on failure.
- */
-struct heci_cb_private *
-find_pthi_read_list_entry(
- struct iamt_heci_device *dev,
- struct heci_file *file)
-{
- struct heci_file_private *file_ext_temp;
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
-
- if ((dev->pthi_read_complete_list.status == 0) &&
- !list_empty(&dev->pthi_read_complete_list.heci_cb.cb_list)) {
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->pthi_read_complete_list.heci_cb.cb_list, cb_list,
- struct heci_cb_private) {
-
- file_ext_temp = (struct heci_file_private *)
- priv_cb_pos->file_private;
- if ((file_ext_temp != NULL) &&
- (file_ext_temp == &dev->iamthif_file_ext) &&
- (priv_cb_pos->file_object == file))
- return (priv_cb_pos);
- }
- }
- return (NULL);
-}
-
-/*
- * pthi_read - read data from pthi client
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @file: pointer to file object
- * @*ubuf: pointer to user data in user space
- * @length: data length to read
- * @offset: data read offset
- *
- * @return
- * returned data length on success,
- * zero if no data to read,
- * negative on failure.
- */
-int
-pthi_read(struct iamt_heci_device *dev, int if_num, struct heci_file *file,
- struct uio *uio_p)
-{
-
- int rets = 0;
- struct heci_cb_private *priv_cb = NULL;
- struct heci_file_private *file_ext = file->private_data;
- uint8_t i;
- unsigned long currtime = ddi_get_time();
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev))
- return (-ENODEV);
-
- if ((file_ext == NULL) || (file_ext != &dev->iamthif_file_ext))
- return (-ENODEV);
-
- mutex_enter(&dev->device_lock);
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id ==
- dev->iamthif_file_ext.me_client_id)
- break;
- }
- ASSERT(dev->me_clients[i].client_id == file_ext->me_client_id);
- if ((i == dev->num_heci_me_clients) ||
- (dev->me_clients[i].client_id !=
- dev->iamthif_file_ext.me_client_id)) {
- DBG("PTHI client not found.\n");
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- priv_cb = find_pthi_read_list_entry(dev, file);
- if (!priv_cb) {
- mutex_exit(&dev->device_lock);
- return (0); /* No more data to read */
- } else {
- if (priv_cb &&
- (currtime - priv_cb->read_time > IAMTHIF_READ_TIMER)) {
- /* 15 sec for the message has expired */
- list_del(&priv_cb->cb_list);
- mutex_exit(&dev->device_lock);
- rets = -ETIMEDOUT;
- goto free;
- }
- /* if the whole message will fit remove it from the list */
- if ((priv_cb->information >= UIO_OFFSET(uio_p)) &&
- (UIO_LENGTH(uio_p) >=
- (priv_cb->information - UIO_OFFSET(uio_p)))) {
-
- list_del(&priv_cb->cb_list);
-
- } else if ((priv_cb->information > 0) &&
- (priv_cb->information <= UIO_OFFSET(uio_p))) {
-
- /* end of the message has been reached */
- list_del(&priv_cb->cb_list);
- rets = 0;
- mutex_exit(&dev->device_lock);
- goto free;
- }
- /*
- * else means that not full buffer will be read and do not
- * remove message from deletion list
- */
- }
- DBG("pthi priv_cb->response_buffer size - %d\n",
- priv_cb->response_buffer.size);
- DBG("pthi priv_cb->information - %lu\n",
- priv_cb->information);
- mutex_exit(&dev->device_lock);
-
- rets = uiomove(priv_cb->response_buffer.data,
- min(uio_p->uio_resid, priv_cb->information),
- UIO_READ, uio_p);
-free:
- DBG("free pthi cb memory.\n");
- kmem_free(priv_cb->request_buffer.data, priv_cb->request_buffer.size);
- kmem_free(priv_cb->response_buffer.data, priv_cb->response_buffer.size);
- kmem_free(priv_cb, sizeof (struct heci_cb_private));
- return (rets);
-}
-
-/*
- * heci_start_read - the start read client message function.
- *
- * @dev: Device object for our driver
- * @if_num: minor number
- * @file_ext: private data of the file object
- *
- * @return 0 on success, <0 on failure.
- */
-int
-heci_start_read(struct iamt_heci_device *dev, int if_num,
- struct heci_file_private *file_ext)
-{
- int rets = 0;
- uint8_t i;
- struct heci_cb_private *priv_cb = NULL;
-
- if ((if_num < HECI_MINOR_NUMBER) || (!dev) || (!file_ext)) {
- DBG("received wrong function input param.\n");
- return (-ENODEV);
- }
- if (file_ext->state != HECI_FILE_CONNECTED)
- return (-ENODEV);
-
- mutex_enter(&dev->device_lock);
- if (dev->heci_state != HECI_ENABLED) {
- mutex_exit(&dev->device_lock);
- return (-ENODEV);
- }
- mutex_exit(&dev->device_lock);
- DBG("check if read is pending.\n");
- if ((file_ext->read_pending) || (file_ext->read_cb != NULL)) {
- DBG("read is pending.\n");
- return (-EBUSY);
- }
- priv_cb = kmem_zalloc(sizeof (struct heci_cb_private), KM_SLEEP);
- if (!priv_cb)
- return (-ENOMEM);
-
- DBG("allocation call back success\n"
- "host client = %d, ME client = %d\n",
- file_ext->host_client_id, file_ext->me_client_id);
- mutex_enter(&dev->device_lock);
- for (i = 0; i < dev->num_heci_me_clients; i++) {
- if (dev->me_clients[i].client_id == file_ext->me_client_id)
- break;
-
- }
-
- ASSERT(dev->me_clients[i].client_id == file_ext->me_client_id);
- if (i == dev->num_heci_me_clients) {
- rets = -ENODEV;
- goto unlock;
- }
-
- priv_cb->response_buffer.size = dev->me_clients[i].props.max_msg_length;
- mutex_exit(&dev->device_lock);
- priv_cb->response_buffer.data =
- kmem_zalloc(priv_cb->response_buffer.size, KM_SLEEP);
- if (!priv_cb->response_buffer.data) {
- rets = -ENOMEM;
- goto fail;
- }
- DBG("allocation call back data success.\n");
- priv_cb->major_file_operations = HECI_READ;
- /* make sure information is zero before we start */
- priv_cb->information = 0;
- priv_cb->file_private = (void *)file_ext;
- file_ext->read_cb = priv_cb;
- mutex_enter(&dev->device_lock);
- if (dev->host_buffer_is_empty) {
- dev->host_buffer_is_empty = 0;
- if (!heci_send_flow_control(dev, file_ext)) {
- rets = -ENODEV;
- goto unlock;
- } else {
- list_add_tail(&priv_cb->cb_list,
- &dev->read_list.heci_cb.cb_list);
- }
- } else {
- list_add_tail(&priv_cb->cb_list,
- &dev->ctrl_wr_list.heci_cb.cb_list);
- }
- mutex_exit(&dev->device_lock);
- return (rets);
-unlock:
- mutex_exit(&dev->device_lock);
-fail:
- heci_free_cb_private(priv_cb);
- return (rets);
-}
-
-/*
- * pthi_write: write iamthif data to pthi client
- *
- * @dev: Device object for our driver
- * @priv_cb: heci call back struct
- *
- * @return 0 on success, <0 on failure.
- */
-int
-pthi_write(struct iamt_heci_device *dev,
- struct heci_cb_private *priv_cb)
-{
- int rets = 0;
- struct heci_msg_hdr heci_hdr;
-
- if ((!dev) || (!priv_cb))
- return (-ENODEV);
-
- DBG("write data to pthi client.\n");
-
- dev->iamthif_state = HECI_IAMTHIF_WRITING;
- dev->iamthif_current_cb = priv_cb;
- dev->iamthif_file_object = priv_cb->file_object;
- dev->iamthif_canceled = 0;
- dev->iamthif_ioctl = 1;
- dev->iamthif_msg_buf_size = priv_cb->request_buffer.size;
- (void) memcpy(dev->iamthif_msg_buf, priv_cb->request_buffer.data,
- priv_cb->request_buffer.size);
-
- if (flow_ctrl_creds(dev, &dev->iamthif_file_ext) &&
- dev->host_buffer_is_empty) {
- dev->host_buffer_is_empty = 0;
- if (priv_cb->request_buffer.size >
- (((dev->host_hw_state & H_CBD) >> 24) *
- sizeof (uint32_t)) - sizeof (struct heci_msg_hdr)) {
- heci_hdr.length =
- (((dev->host_hw_state & H_CBD) >> 24) *
- sizeof (uint32_t)) - sizeof (struct heci_msg_hdr);
- heci_hdr.msg_complete = 0;
- } else {
- heci_hdr.length = priv_cb->request_buffer.size;
- heci_hdr.msg_complete = 1;
- }
-
- heci_hdr.host_addr = dev->iamthif_file_ext.host_client_id;
- heci_hdr.me_addr = dev->iamthif_file_ext.me_client_id;
- heci_hdr.reserved = 0;
- dev->iamthif_msg_buf_index += heci_hdr.length;
- if (!heci_write_message(dev, &heci_hdr,
- (unsigned char *)(dev->iamthif_msg_buf),
- heci_hdr.length))
- return (-ENODEV);
-
- if (heci_hdr.msg_complete) {
- flow_ctrl_reduce(dev, &dev->iamthif_file_ext);
- dev->iamthif_flow_control_pending = 1;
- dev->iamthif_state = HECI_IAMTHIF_FLOW_CONTROL;
- DBG("add pthi cb to write waiting list\n");
- dev->iamthif_current_cb = priv_cb;
- dev->iamthif_file_object = priv_cb->file_object;
- list_add_tail(&priv_cb->cb_list,
- &dev->write_waiting_list.heci_cb.cb_list);
- } else {
- DBG("message does not complete, "
- "so add pthi cb to write list.\n");
- list_add_tail(&priv_cb->cb_list,
- &dev->write_list.heci_cb.cb_list);
- }
- } else {
- if (!(dev->host_buffer_is_empty))
- DBG("host buffer is not empty");
-
- DBG("No flow control credentials, "
- "so add iamthif cb to write list.\n");
- list_add_tail(&priv_cb->cb_list,
- &dev->write_list.heci_cb.cb_list);
- }
- return (rets);
-}
-
-/*
- * iamthif_ioctl_send_msg - send cmd data to pthi client
- *
- * @dev: Device object for our driver
- *
- * @return 0 on success, <0 on failure.
- */
-void
-run_next_iamthif_cmd(struct iamt_heci_device *dev)
-{
- struct heci_file_private *file_ext_tmp;
- struct heci_cb_private *priv_cb_pos = NULL;
- struct heci_cb_private *priv_cb_next = NULL;
- int status = 0;
-
- if (!dev)
- return;
-
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = 0;
- dev->iamthif_ioctl = 1;
- dev->iamthif_state = HECI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
- dev->iamthif_file_object = NULL;
-
- if (dev->pthi_cmd_list.status == 0 &&
- !list_empty(&dev->pthi_cmd_list.heci_cb.cb_list)) {
- DBG("complete pthi cmd_list cb.\n");
-
- list_for_each_entry_safe(priv_cb_pos, priv_cb_next,
- &dev->pthi_cmd_list.heci_cb.cb_list, cb_list,
- struct heci_cb_private) {
-
- list_del(&priv_cb_pos->cb_list);
- file_ext_tmp = (struct heci_file_private *)
- priv_cb_pos->file_private;
-
- if ((file_ext_tmp != NULL) &&
- (file_ext_tmp == &dev->iamthif_file_ext)) {
- status = pthi_write(dev, priv_cb_pos);
- if (status != 0) {
- DBG("pthi write failed status = %d\n",
- status);
- return;
- }
- break;
- }
- }
- }
-}
-
-/*
- * heci_free_cb_private - free heci_cb_private related memory
- *
- * @priv_cb: heci callback struct
- */
-void
-heci_free_cb_private(struct heci_cb_private *priv_cb)
-{
- if (priv_cb == NULL)
- return;
-
- kmem_free(priv_cb->request_buffer.data, priv_cb->request_buffer.size);
- kmem_free(priv_cb->response_buffer.data, priv_cb->response_buffer.size);
- kmem_free(priv_cb, sizeof (struct heci_cb_private));
-}
-
-/*
- * heci_fe_same_id - tell if file private data have same id
- *
- * @fe1: private data of 1. file object
- * @fe2: private data of 2. file object
- *
- * @return !=0 - if ids are the same, 0 - if differ.
- */
-static inline int heci_fe_same_id(struct heci_file_private *fe1,
- struct heci_file_private *fe2)
-{
- return ((fe1->host_client_id == fe2->host_client_id) &&
- (fe1->me_client_id == fe2->me_client_id));
-}
diff --git a/usr/src/uts/intel/io/heci/version.h b/usr/src/uts/intel/io/heci/version.h
deleted file mode 100644
index 5aa067f2b8..0000000000
--- a/usr/src/uts/intel/io/heci/version.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Part of "Intel(R) AMT Management Interface" Linux driver
- *
- * Copyright (c) 2006-2007 Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-#ifndef HECI_VERSION_H
-#define HECI_VERSION_H
-
-#define MAJOR_VERSION 5
-#define MINOR_VERSION 0
-#define QUICK_FIX_NUMBER 0
-#define VER_BUILD 30
-
-#endif /* HECI_VERSION_H */