3
// $Workfile: imb_api.h $
5
// $Modtime: Jul 22 2002 16:40:32 $
8
// Combined include files needed for imbapi.c
11
/*----------------------------------------------------------------------*
13
Copyright (c) 2002, Intel Corporation
15
Redistribution and use in source and binary forms, with or without
16
modification, are permitted provided that the following conditions are met:
17
a.. Redistributions of source code must retain the above copyright notice,
18
this list of conditions and the following disclaimer.
19
b.. Redistributions in binary form must reproduce the above copyright notice,
20
this list of conditions and the following disclaimer in the documentation
21
and/or other materials provided with the distribution.
22
c.. Neither the name of Intel Corporation nor the names of its contributors
23
may be used to endorse or promote products derived from this software
24
without specific prior written permission.
25
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
29
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
*----------------------------------------------------------------------*/
48
/* WIN32 defines this in stdio.h */
61
typedef unsigned long DWORD;
63
typedef unsigned char BYTE;
64
typedef unsigned short WORD;
66
typedef FLOAT *PFLOAT;
67
typedef BOOL near *PBOOL;
68
typedef BOOL far *LPBOOL;
69
typedef BYTE near *PBYTE;
70
typedef BYTE far *LPBYTE;
71
typedef int near *PINT;
72
typedef int far *LPINT;
73
typedef WORD near *PWORD;
74
typedef WORD far *LPWORD;
75
typedef long far *LPLONG;
76
typedef DWORD near *PDWORD;
77
typedef DWORD far *LPDWORD;
78
typedef void far *LPVOID;
79
typedef CONST void far *LPCVOID;
81
typedef unsigned int UINT;
82
typedef unsigned int *PUINT;
83
typedef DWORD NTSTATUS;
88
typedef struct _OVERLAPPED {
94
} OVERLAPPED, *LPOVERLAPPED;
97
* Data structure redefines
102
typedef char * PCHAR;
103
typedef short * PSHORT;
104
typedef long * PLONG;
105
typedef unsigned char UCHAR;
106
typedef unsigned short USHORT;
107
typedef unsigned long ULONG;
108
typedef unsigned char * PUCHAR;
109
typedef unsigned short * PUSHORT;
110
typedef unsigned long * PULONG;
112
typedef short CSHORT;
114
typedef CCHAR * PCCHAR;
115
typedef CSHORT * PCSHORT;
116
typedef CLONG * PCLONG;
117
typedef void * PVOID;
120
typedef struct _LARGE_INTEGER {
124
typedef struct _ULARGE_INTEGER {
129
typedef LARGE_INTEGER * PLARGE_INTEGER;
130
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
131
typedef LARGE_INTEGER * PPHYSICAL_ADDRESS;
132
typedef ULARGE_INTEGER * PULARGE_INTEGER;
133
typedef UCHAR BOOLEAN;
134
typedef BOOLEAN *PBOOLEAN;
135
typedef wchar_t WCHAR;
136
typedef WCHAR *PWCHAR, *PWSTR;
137
typedef CONST WCHAR *LPCWSTR, *PCWSTR;
142
typedef char * caddr_t;
146
Unicode strings are counted 16-bit character strings. If they are
147
NULL terminated, Length does not include trailing NULL.
149
typedef struct _UNICODE_STRING {
151
USHORT MaximumLength;
154
typedef UNICODE_STRING *PUNICODE_STRING;
155
#define UNICODE_NULL ((WCHAR)0) /* winnt*/
158
#define OPTIONAL /* */
161
#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
162
#define UNREFERENCED_PARAMETER(x)
164
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
166
typedef HANDLE *PHANDLE;
168
Define the method codes for how buffers are passed for I/O and FS controls
170
#define METHOD_BUFFERED 0
172
Define the access check value for any access
173
The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
174
ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
175
constants *MUST* always be in sync.
177
#define FILE_ANY_ACCESS 0
179
These are the generic rights.
182
#define GetLastError() (NTstatus.Status)
184
Macro definition for defining IOCTL and FSCTL function control codes. Note
185
that function codes 0-2047 are reserved for Microsoft Corporation, and
186
2048-4095 are reserved for customers.
189
* Linux drivers expect ioctls defined using macros defined in ioctl.h.
190
* So, instead of using the CTL_CODE defined for NT and UW, I define CTL_CODE
191
* using these macros. That way imb_if.h, where the ioctls are defined get
192
* to use the correct ioctl command we expect.
193
* Notes: I am using the generic _IO macro instead of the more specific
194
* ones. The macros expect 8bit entities, so I am cleaning what is sent to
195
* us from imb_if.h - Mahendra
198
#define CTL_CODE(DeviceType, Function, Method, Access)\
199
_IO(DeviceType & 0x00FF, Function & 0x00FF)
201
#define CTL_CODE( DeviceType, Function, Method, Access ) ((ULONG)( \
202
((ULONG)(DeviceType) << 16) | ((ULONG)(Access) << 14) | ((ULONG)(Function) << 2) | ((ULONG)Method) \
205
#endif /*_WINDEFS_H */
206
/*----------------------------------------------------------------------*/
209
#define SMI_Version1_00 0x00001000
214
LPVOID ntstatus; /* address of NT status block*/
215
LPVOID lpvInBuffer; /* address of buffer for input data*/
216
DWORD cbInBuffer; /* size of input buffer*/
217
LPVOID lpvOutBuffer; /* address of output buffer*/
218
DWORD cbOutBuffer; /* size of output buffer*/
219
LPDWORD lpcbBytesReturned; /* address of actual bytes of output*/
220
LPOVERLAPPED lpoOverlapped; /* address of overlapped structure*/
222
#ifndef STATUS_SUCCESS
223
typedef struct _IO_STATUS_BLOCK {
226
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
228
* I2C ioctl's return NTStatus codes
230
#define STATUS_SUCCESS (0x00000000U)
231
#define STATUS_UNSUCCESSFUL (0xC0000001U)
232
#define STATUS_DEVICE_BUSY (0x80000011U)
234
#define STATUS_PENDING (0x00000103U)
235
// see <win2000ddk>\inc\winnt.h(1171)
237
#define STATUS_INVALID_PARAMETER (0xC000000DU)
238
#define STATUS_INVALID_DEVICE_REQUEST (0xC0000010U)
239
#define STATUS_BUFFER_TOO_SMALL (0xC0000023U)
240
#define STATUS_FILE_CLOSED (0xC0000128U)
241
#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AU)
242
#define STATUS_NO_DATA_DETECTED (0x80000022U)
243
#define STATUS_NO_SUCH_DEVICE (0xC000000EU)
244
#define STATUS_ALLOTTED_EXCEEDED (0xC000000FU)
245
#define STATUS_IO_DEVICE_ERROR (0xC0000185U)
246
#define STATUS_TOO_MANY_OPEN_FILES (0xC000011FU)
247
#define STATUS_ACCESS_DENIED (0xC0000022U)
248
#define STATUS_BUFFER_OVERFLOW (0x80000005U)
249
#define STATUS_CANCELLED (0xC0000120U)
250
#endif /* STATUS_SUCCESS*/
252
/*----------------------------------------------------------------------*/
256
* This is the structure passed in to the IOCTL_IMB_SHUTDOWN_CODE request
262
#define SD_NO_ACTION 0
264
#define SD_POWER_OFF 2
267
* This is the generic IMB packet format, the final checksum cant be
268
* represented in this structure and will show up as the last data byte
279
#define MIN_IMB_PACKET_SIZE 7
280
#define MAX_IMB_PACKET_SIZE 33
282
* This is the standard IMB response format where the first byte of
283
* IMB packet data is interpreted as a command completion code.
295
#define MIN_IMB_RESPONSE_SIZE 7 /* min packet + completion code */
296
#define MAX_IMB_RESPONSE_SIZE MAX_IMB_PACKET_SIZE
297
/************************
299
************************/
301
// Name: ImbRequestBuffer
302
// Purpose: Structure definition for holding IMB message data
303
// Context: Used by SendTimedImbpMessage and SendTimedI2cMessge
304
// functions in the library interface. In use, it is overlayed on a
305
// char buffer of size MIN_IMB_REQ_BUF_SIZE +
307
// respBufSize size of the response buffer
309
// timeout timeout value in milli seconds
311
// req body of request to send
323
DWORD flags; /* request flags*/
324
#define NO_RESPONSE_EXPECTED 0x01 /*dont wait around for an IMB response*/
325
DWORD timeOut; /* in uSec units*/
326
ImbRequest req; /* message buffer*/
328
#define MIN_IMB_REQ_BUF_SIZE 13 /* a buffer without any request data*/
329
/************************
331
************************/
333
// Name: ImbResponseBuffer
334
// Purpose: Structure definition for response of a previous send
335
// Context: Used by DeviceIoControl to pass the message to be sent to
338
// cCode completion code returned by firmware
339
// data buffer for response data from firmware
345
#define MIN_IMB_RESP_BUF_SIZE 1
346
#define MAX_IMB_RESP_SIZE (MIN_IMB_RESP_BUF_SIZE + MAX_IMB_RESPONSE_SIZE)
349
* Async message access structures and types
351
typedef DWORD ImbAsyncSeq;
353
* This is the structure passed in to IOCTL_IMB_GET_ASYNC_MSG
359
#define ASYNC_SEQ_START 0
364
#define MIN_ASYNC_RESP_SIZE sizeof( ImbAsyncSeq )
365
#define MAX_ASYNC_RESP_SIZE (MIN_ASYNC_RESP_SIZE + MAX_IMB_PACKET_SIZE)
368
** In Linux, these calculate to:
369
** IOCTL_IMB_SEND_MESSAGE =1082
370
** IOCTL_IMB_GET_ASYNC_MSG =1088
371
** IOCTL_IMB_MAP_MEMORY =108e
372
** IOCTL_IMB_UNMAP_MEMORY =1090
373
** IOCTL_IMB_SHUTDOWN_CODE =1092
374
** IOCTL_IMB_REGISTER_ASYNC_OBJ =1098
375
** IOCTL_IMB_DEREGISTER_ASYNC_OBJ=109a
376
** IOCTL_IMB_CHECK_EVENT =109c
377
** IOCTL_IMB_POLL_ASYNC =1094
379
#define FILE_DEVICE_IMB 0x00008010
380
#define IOCTL_IMB_BASE 0x00000880
381
#define IOCTL_IMB_SEND_MESSAGE CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 2), METHOD_BUFFERED, FILE_ANY_ACCESS)
382
#define IOCTL_IMB_GET_ASYNC_MSG CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 8), METHOD_BUFFERED, FILE_ANY_ACCESS)
383
#define IOCTL_IMB_MAP_MEMORY CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 14), METHOD_BUFFERED, FILE_ANY_ACCESS)
384
#define IOCTL_IMB_UNMAP_MEMORY CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 16), METHOD_BUFFERED, FILE_ANY_ACCESS)
385
#define IOCTL_IMB_SHUTDOWN_CODE CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 18), METHOD_BUFFERED, FILE_ANY_ACCESS)
386
#define IOCTL_IMB_REGISTER_ASYNC_OBJ CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 24), METHOD_BUFFERED, FILE_ANY_ACCESS)
387
#define IOCTL_IMB_DEREGISTER_ASYNC_OBJ CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 26), METHOD_BUFFERED, FILE_ANY_ACCESS)
388
#define IOCTL_IMB_CHECK_EVENT CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 28), METHOD_BUFFERED, FILE_ANY_ACCESS)
389
#define IOCTL_IMB_POLL_ASYNC CTL_CODE(FILE_DEVICE_IMB, (IOCTL_IMB_BASE + 20), METHOD_BUFFERED, FILE_ANY_ACCESS)
390
#endif /* IMB_IF__ */
391
/*----------------------------------------------------------------------*/
392
/* No asynchronous messages available */
393
#define IMB_MSG_NOT_AVAILABLE ((NTSTATUS)0xE0070012L)
395
/* Define the facility codes */
396
#define FACILITY_RPC_STUBS 0x3
397
#define FACILITY_RPC_RUNTIME 0x2
398
#define FACILITY_IO_ERROR_CODE 0x4
399
#define IMB_IO_ERROR_CODE 0x7
401
#define STATUS_SEVERITY_WARNING 0x2
402
#define STATUS_SEVERITY_SUCCESS 0x0
403
#define STATUS_SEVERITY_INFORMATIONAL 0x1
404
#define STATUS_SEVERITY_ERROR 0x3
405
/* Not enough memory for internal storage of device %1. */
406
#define INSUFFICIENT_RESOURCES ((NTSTATUS)0xE0070001L)
408
#define INVALID_INPUT_BUFFER ((NTSTATUS)0xE0070002L)
410
#define INVALID_OUTPUT_BUFFER ((NTSTATUS)0xE0070003L)
412
#define IMB_SEND_TIMEOUT ((NTSTATUS)0xE0070004L)
414
#define IMB_RECEIVE_TIMEOUT ((NTSTATUS)0xE0070005L)
416
#define IMB_IF_SEND_TIMEOUT ((NTSTATUS)0xE0070006L)
418
#define IMB_IF_RECEIVE_TIMEOUT ((NTSTATUS)0xE0040007L)
420
#define HARDWARE_FAILURE ((NTSTATUS)0xE0040008L)
422
#define DRIVER_FAILURE ((NTSTATUS)0xE0040009L)
424
#define IMB_INVALID_IF_RESPONSE ((NTSTATUS)0xE004000AL)
426
#define IMB_INVALID_PACKET ((NTSTATUS)0xE004000BL)
428
#define IMB_RESPONSE_DATA_OVERFLOW ((NTSTATUS)0xE004000CL)
430
#define IMB_INVALID_REQUEST ((NTSTATUS)0xE007000DL)
432
#define INVALID_DRIVER_IOCTL ((NTSTATUS)0xE007000EL)
434
#define INVALID_DRIVER_REQUEST ((NTSTATUS)0xE007000FL)
436
#define IMB_CANT_GET_SMS_BUFFER ((NTSTATUS)0xE0070010L)
438
#define INPUT_BUFFER_TOO_SMALL ((NTSTATUS)0xE0070011L)
440
#define IMB_SEND_ERROR ((NTSTATUS)0xE0070013L)
441
#endif /* IMBLOG_H__ */
442
/*----------------------------------------------------------------------*/
445
#include <sys/types.h>
446
#define WRITE_READ_I2C 0x52
447
#define WRITE_EMP_BUFFER 0x7a
448
#define GET_DEVICE_ID 0x1
449
#define SEND_MESSAGE 0x34
452
#define APP_NETFN 0x06
453
#define IPMI_09_VERSION 0x90
454
#define IPMI_10_VERSION 0x01
456
#define IPMI_15_VERSION 0x51
458
#ifndef IPMI10_GET_DEVICE_ID_RESP_LENGTH
459
#define IPMI10_GET_DEVICE_ID_RESP_LENGTH 12
462
#define IPMB_CHANNEL 0x0
463
#define EMP_CHANNEL 0x1
464
#define LAN_CHANNEL 0x2
465
#define RESERVED_LUN 0x3
471
#define BMC_CONTROLLER 0x20
472
#define FPC_CONTROLLER 0x22
479
ACCESN_INVALID_TRANSACTION,
484
* Request structure provided to SendTimedImbpRequest()
487
unsigned char cmdType;
489
unsigned char busType;
492
unsigned char * data;
496
* Request structure provided to SendTimedI2cRequest()
500
unsigned char busType;
501
unsigned char numberOfBytesToRead;
502
unsigned char * data;
508
* This section is provided to be able to compile using imb_if.h
511
* function return type. This is also defined in the local instrumentation
512
* so we ifdef here to avoid conflict.
514
#define METHOD_BUFFERED 0
515
#define FILE_ANY_ACCESS 0
517
* This is necessary to compile using memIf.h
519
typedef enum _INTERFACE_TYPE
527
} INTERFACE_TYPE, * PINTERFACE_TYPE;
533
INTERFACE_TYPE InterfaceType; // Isa, Eisa, etc....
534
ULONG BusNumber; // Bus number
535
PHYSICAL_ADDRESS BusAddress; // Bus-relative address
536
ULONG AddressSpace; // 0 is memory, 1 is I/O
537
ULONG Length; // Length of section to map
538
} PHYSICAL_MEMORY_INFO, * PPHYSICAL_MEMORY_INFO;
541
/*#else // not IMB_API */
543
* These are defined in imb_if.h but are needed by users of the imbapi library
545
#define ASYNC_SEQ_START 0
547
* This is the generic IMB packet format, the final checksum cant be
548
* represented in this structure and will show up as the last data byte
551
#define MIN_IMB_PACKET_SIZE 7
552
#define MAX_IMB_PACKET_SIZE 33
554
#define MAX_BUFFER_SIZE 64
555
/*#endif // IMB_API */
556
/******************************
557
* FUNCTION PROTOTYPES
558
******************************/
560
SendTimedImbpRequest (
561
IMBPREQUESTDATA *reqPtr,
565
BYTE * completionCode
568
SendTimedI2cRequest (
569
I2CREQUESTDATA *reqPtr,
573
BYTE * completionCode
576
SendAsyncImbpRequest (
577
IMBPREQUESTDATA *reqPtr,
581
GetAsyncImbpMessage (
589
GetAsyncImbpMessage_Ex (
595
BYTE * sessionHandle,
599
UnmapPhysicalMemory( int virtualAddress, int Length );
601
StartAsyncMesgPoll(void);
614
SendTimedEmpMessageResponse (
616
char *responseDataBuf,
621
SendTimedEmpMessageResponse_Ex (
623
char *responseDataBuf,
630
SendTimedLanMessageResponse (
632
char *responseDataBuf,
637
SendTimedLanMessageResponse_Ex (
639
char *responseDataBuf,
646
IsAsyncMessageAvailable (unsigned int eventId );
648
RegisterForImbAsyncMessageNotification (unsigned int *handleId);
650
UnRegisterForImbAsyncMessageNotification (unsigned int handleId,int iFlag);
651
BYTE GetIpmiVersion(void);
652
#endif /* IMBAPI_H__ */