xref: /titanic_41/usr/src/cmd/lms/heci/heci.h (revision c037192b037119c9fd354732fc29b38ce097d356)
1 /*******************************************************************************
2  * Copyright (C) 2004-2008 Intel Corp. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *  - Redistributions of source code must retain the above copyright notice,
8  *    this list of conditions and the following disclaimer.
9  *
10  *  - Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  *
14  *  - Neither the name of Intel Corp. nor the names of its
15  *    contributors may be used to endorse or promote products derived from this
16  *    software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL Intel Corp. OR THE CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *******************************************************************************/
30 
31 #ifndef __HECI_H__
32 #define __HECI_H__
33 
34 #include <cstring>
35 
36 #ifdef __sun
37 #include <string.h>
38 #endif	// __sun
39 
40 #ifndef GUID_DEFINED
41 #define GUID_DEFINED
42 
43 typedef struct guid {
44 	unsigned int   data1;
45 	unsigned short data2;
46 	unsigned short data3;
47 	unsigned char  data4[8];
48 } GUID;
49 
50 #endif
51 
52 #include "HECI_if.h"
53 
54 class HECI
55 {
56 public:
57 	HECI(const GUID guid, bool verbose = true) :
58 	    _initialized(false),
59 	    _verbose(verbose),
60 	    _bufSize(0),
61 	    _protocolVersion(0)
62 	{
63 		memcpy(&_guid, &guid, sizeof(_guid));
64 	}
65 	virtual ~HECI() {}
66 
67 	virtual bool Init(unsigned char maxProtocolVersion = 0) = 0;
68 	virtual void Deinit() = 0;
69 	virtual int ReceiveMessage(unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
70 	virtual int SendMessage(const unsigned char *buffer, int len, unsigned long timeout = 2000) = 0;
71 	virtual unsigned int GetBufferSize() const = 0;
72 	virtual unsigned char GetProtocolVersion() const = 0;
73 	virtual bool GetHeciVersion(HECI_VERSION &version) const = 0;
74 	virtual bool IsInitialized() const = 0;
75 
76 protected:
77 	GUID _guid;
78 	bool _initialized;
79 	bool _verbose;
80 	unsigned int  _bufSize;
81 	unsigned char _protocolVersion;
82 };
83 
84 #endif
85