1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
****************************************************************
** **
** (C)Copyright 2006-2009, American Megatrends Inc. **
** **
** All Rights Reserved. **
** **
** 5555 Oakbrook Pkwy Suite 200, Norcross, **
** **
** Georgia - 30093, USA. Phone-(770)-246-8600. **
** **
****************************************************************
*/
#ifndef KCS_H
#define KCS_H
#include "kcs_timeout.h"
#define MSG_PAYLOAD_SIZE (33*1024)
#define MAX_KCS_PKT_LEN (33*1024)
#define INT_ENABLE 0x1E
#define POLL_MSEC HZ
/* Different Phases of the KCS Module */
#define KCS_PHASE_IDLE 0x00
#define KCS_PHASE_WRITE 0x01
#define KCS_PHASE_WRITE_END 0x02
#define KCS_PHASE_READ 0x03
#define KCS_PHASE_ABORT 0x04
#define KCS_PHASE_ERROR 0x05
#define ABORT_PHASE_ERROR1 0x02
#define ABORT_PHASE_ERROR2 0x03
/* KCS Error Codes */
#define KCS_NO_ERROR 0x00
#define KCS_ABORTED_BY_COMMAND 0x01
#define KCS_ILLEGAL_CONTROL_CODE 0x02
#define KCS_LENGTH_ERROR 0x06
#define KCS_UNSPECIFIED_ERROR 0xff
/**** Command Completion Codes ****/
#define CC_NORMAL 0x00
/* Different KCS States */
#define KCS_IDLE_STATE 0x00
#define KCS_READ_STATE 0x40
#define KCS_WRITE_STATE 0x80
#define KCS_ERROR_STATE 0xC0
/* KCS Command Control Codes */
#define KCS_GET_STATUS 0x60
#define KCS_ABORT 0x60
#define KCS_WRITE_START 0x61
#define KCS_WRITE_END 0x62
#define KCS_READ 0x68
#define KCS_CHANNEL_NOT_IN_USE 0x00
#define KCS_CHANNEL_IN_USE 0x01
#define TRANSMIT_TIMEOUT 10000 /* Transmission Timeout in msecs */
/* IOCTL related */
#define ARBITRARY_NUM 100
#define MEL_IOCTL_TEST _IOWR(ARBITRARY_NUM, 0, int)
#define MEL_IOCTL_READ _IOR(ARBITRARY_NUM, 1, struct ioctl_t *)
#define MEL_IOCTL_WRITE _IOW(ARBITRARY_NUM, 4, struct ioctl_t *)
#define KCS_PROC_ROOT_DIR "bmc"
typedef struct
{
u32 KCSRcvPktIx;
u8* pKCSRcvPkt;
u32 KCSSendPktIx;
u32 KCSSendPktLen;
u8* pKCSSendPkt;
u8 KCSPhase;
u8 AbortPhase;
u8 KCSError;
u8 FirstTime;
Kcs_OsSleepStruct KcsReqWait;
u8 KcsIFActive;
u8 KcsWakeup;
u8 KcsResFirstTime;
u8 KcsINuse;
Kcs_OsSleepStruct KcsResWait;
u8 KcsWtIFActive;
u8 TxReady;
u8 PrevCmdAborted;
// Event_T KCSRcvPktReady;
} __attribute__((packed)) KCSBuf_T;
typedef struct
{
u8 Channel; /**< Originator's channel number*/
//HQueue_T hSrcQ; /**< Originator Queue*/
u8 Param; /**< Parameter*/
u8 Cmd; /**< Command that needs to be processed*/
u8 NetFnLUN; /**< Net function and LUN of command*/
u8 Privilege; /**< Current privilege level*/
u32 SessionID; /**< Session ID if any*/
u8 RequestSize; /**< Size of the Request*/
u8 Request [MSG_PAYLOAD_SIZE]; /**< Request Data buffer*/
u32 ResponseSize; /**< Size of the response*/ //Modified by winston for YAFU
u8 Response [MSG_PAYLOAD_SIZE]; /**< Response Data buffer*/
u8* pRequest; /**< Pointer to Request data*/
u8* pResponse; /**< Pointer to Response data*/
} __attribute__((packed)) IPMICmdMsg_T;
/* KCS Request Structure */
typedef struct
{
u8 NetFnLUN;
u8 Cmd;
} __attribute__((packed)) KCSReq_T;
typedef struct
{
unsigned char (*num_kcs_ch) (void);
void (*enable_kcs_interrupt) (void);
void (*disable_kcs_interrupt) (void);
void (*read_kcs_status) (u8 ch_num, u8* status_value);
void (*write_kcs_status) (u8 ch_num, u8 status_value);
void (*read_kcs_command) (u8 ch_num, u8* command);
void (*read_kcs_data_in) (u8 ch_num, u8* data_value);
void (*write_kcs_data_out) (u8 ch_num, u8 data_value);
void (*kcs_interrupt_enable_user) (void);
void (*kcs_interrupt_disable_user) (void);
} kcs_driver_operations_t;
int kcs_init (kcs_driver_operations_t *devops, unsigned char ch_num, struct module* owner);
void kcs_exit (void);
int process_kcs_intr (unsigned char ch_num);
#endif /* KCS_H */
|