• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/char/ipmi/

Lines Matching defs:bt

82 #define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; }
117 variable "bt" is hardcoded into these macros. */
119 #define BT_STATUS bt->io->inputb(bt->io, 0)
120 #define BT_CONTROL(x) bt->io->outputb(bt->io, 0, x)
122 #define BMC2HOST bt->io->inputb(bt->io, 1)
123 #define HOST2BMC(x) bt->io->outputb(bt->io, 1, x)
125 #define BT_INTMASK_R bt->io->inputb(bt->io, 2)
126 #define BT_INTMASK_W(x) bt->io->outputb(bt->io, 2, x)
151 #define STATE2TXT state2txt(bt->state)
182 static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
184 memset(bt, 0, sizeof(struct si_sm_data));
185 if (bt->io != io) { /* external: one-time only things */
186 bt->io = io;
187 bt->seq = 0;
189 bt->state = BT_STATE_IDLE; /* start here */
190 bt->complete = BT_STATE_IDLE; /* end here */
191 bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * 1000000;
192 bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT;
199 static void force_result(struct si_sm_data *bt, unsigned char completion_code)
201 bt->read_data[0] = 4; /* # following bytes */
202 bt->read_data[1] = bt->write_data[1] | 4; /* Odd NetFn/LUN */
203 bt->read_data[2] = bt->write_data[2]; /* seq (ignored) */
204 bt->read_data[3] = bt->write_data[3]; /* Command */
205 bt->read_data[4] = completion_code;
206 bt->read_count = 5;
211 static int bt_start_transaction(struct si_sm_data *bt,
222 if (bt->state == BT_STATE_LONG_BUSY)
225 if (bt->state != BT_STATE_IDLE)
235 bt->write_data[0] = size + 1; /* all data plus seq byte */
236 bt->write_data[1] = *data; /* NetFn/LUN */
237 bt->write_data[2] = bt->seq++;
238 memcpy(bt->write_data + 3, data + 1, size - 1);
239 bt->write_count = size + 2;
240 bt->error_retries = 0;
241 bt->nonzero_status = 0;
242 bt->truncated = 0;
243 bt->state = BT_STATE_XACTION_START;
244 bt->timeout = bt->BT_CAP_req2rsp;
245 force_result(bt, IPMI_ERR_UNSPECIFIED);
252 static int bt_get_result(struct si_sm_data *bt,
258 msg_len = bt->read_count - 2; /* account for length & seq */
260 force_result(bt, IPMI_ERR_UNSPECIFIED);
263 data[0] = bt->read_data[1];
264 data[1] = bt->read_data[3];
265 if (length < msg_len || bt->truncated) {
269 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
283 static void reset_flags(struct si_sm_data *bt)
298 static void drain_BMC2HOST(struct si_sm_data *bt)
321 static inline void write_all_bytes(struct si_sm_data *bt)
327 bt->write_count, bt->seq);
328 for (i = 0; i < bt->write_count; i++)
329 printk (" %02x", bt->write_data[i]);
332 for (i = 0; i < bt->write_count; i++)
333 HOST2BMC(bt->write_data[i]);
336 static inline int read_all_bytes(struct si_sm_data *bt)
343 bt->read_data[0] = BMC2HOST;
344 bt->read_count = bt->read_data[0];
346 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
349 bt->read_count);
350 bt->truncated = 1;
353 for (i = 1; i <= bt->read_count; i++)
354 bt->read_data[i] = BMC2HOST;
355 bt->read_count++; /* Account internally for length byte */
358 int max = bt->read_count;
361 max, bt->read_data[2]);
365 printk (" %02x", bt->read_data[i]);
366 printk ("%s\n", bt->read_count == max ? "" : " ...");
370 if ((bt->read_data[3] == bt->write_data[3]) &&
371 (bt->read_data[2] == bt->write_data[2]) &&
372 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
378 bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
379 bt->read_data[1], bt->read_data[2], bt->read_data[3]);
385 static enum si_sm_result error_recovery(struct si_sm_data *bt,
391 bt->timeout = bt->BT_CAP_req2rsp;
407 (bt->error_retries)++;
408 if (bt->error_retries < bt->BT_CAP_retries) {
410 bt->BT_CAP_retries - bt->error_retries);
411 bt->state = BT_STATE_RESTART;
416 bt->BT_CAP_retries);
417 if (!bt->nonzero_status)
421 else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
423 bt->state = BT_STATE_RESET1;
430 bt->state = BT_STATE_IDLE;
435 bt->state = BT_STATE_LONG_BUSY;
441 force_result(bt, cCode);
447 static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
454 bt->nonzero_status |= status;
455 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
459 bt->timeout,
461 last_printed = bt->state;
469 if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
470 drain_BMC2HOST(bt);
474 if ((bt->state != BT_STATE_IDLE) &&
475 (bt->state < BT_STATE_PRINTME)) { /* check timeout */
476 bt->timeout -= time;
477 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
478 return error_recovery(bt,
483 switch (bt->state) {
498 if (!bt->BT_CAP_outreqs)
501 bt->timeout = bt->BT_CAP_req2rsp;
516 write_all_bytes(bt);
551 i = read_all_bytes(bt); /* true == packet seq match */
556 bt->state = bt->complete;
557 return bt->state == BT_STATE_IDLE ? /* where to next? */
563 reset_flags(bt); /* next state is now IDLE */
564 bt_init_data(bt, bt->io);
569 reset_flags(bt);
570 drain_BMC2HOST(bt);
581 bt->timeout = BT_RESET_DELAY * 1000000;
586 if (bt->timeout > 0)
588 drain_BMC2HOST(bt);
593 bt->read_count = 0;
594 bt->nonzero_status = 0;
595 bt->timeout = bt->BT_CAP_req2rsp;
602 bt->BT_CAP_outreqs = 1;
605 bt->state = BT_STATE_IDLE;
606 bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
608 bt->complete = BT_STATE_CAPABILITIES_END;
613 i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
614 bt_init_data(bt, bt->io);
616 bt->BT_CAP_outreqs = BT_CAP[3];
617 bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
618 bt->BT_CAP_retries = BT_CAP[7];
621 if (!bt->BT_CAP_outreqs)
622 bt->BT_CAP_outreqs = 1;
624 bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
625 bt->timeout = bt->BT_CAP_req2rsp;
629 return error_recovery(bt,
636 static int bt_detect(struct si_sm_data *bt)
645 reset_flags(bt);
649 static void bt_cleanup(struct si_sm_data *bt)