20 #include <linux/slab.h>
26 #define HIP_CDUMP_FIRST_CPUREG (0xFFE0)
27 #define HIP_CDUMP_FIRST_LO (0)
28 #define HIP_CDUMP_FIRST_HI_MAC (0x3C00)
29 #define HIP_CDUMP_FIRST_HI_PHY (0x1C00)
30 #define HIP_CDUMP_FIRST_SH (0)
32 #define HIP_CDUMP_NCPUREGS (10)
33 #define HIP_CDUMP_NWORDS_LO (0x0100)
34 #define HIP_CDUMP_NWORDS_HI (0x0400)
35 #define HIP_CDUMP_NWORDS_SH (0x0500)
37 #define HIP_CDUMP_NUM_ZONES 7
120 card->request_coredump_on_reset = enable?1 : 0;
156 if (card->request_coredump_on_reset == 1)
158 card->request_coredump_on_reset = 0;
194 static u16 dump_seq_no = 1;
199 if (card->dump_next_write ==
NULL)
206 if (card->helper ==
NULL)
217 unifi_info(card->ospriv,
"Mini-coredump capture at t=%u\n", time_of_capture);
223 unifi_error(card->ospriv,
"Failed to wake UniFi\n");
233 unifi_error(card->ospriv,
"Failed to stop UniFi XAPs\n");
238 r = unifi_coredump_from_sdio(card, card->dump_next_write);
242 card->dump_next_write->requestor = (req?1 : 0);
243 card->dump_next_write->timestamp = time_of_capture;
245 card->dump_next_write->count = dump_seq_no++;
246 card->dump_cur_read = card->dump_next_write;
247 card->dump_next_write = card->dump_next_write->next;
250 if (dump_seq_no == 0)
256 "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n",
258 card->dump_cur_read->count,
259 card->dump_cur_read, card->dump_next_write);
267 unifi_error(card->ospriv,
"Failed to start UniFi XAPs\n");
299 const u16 offset_in_space)
310 if (space == def->
space)
315 if (offset_in_space < zone_end_offset &&
316 offset_in_space >= def->
offset)
319 offset_in_zone = offset_in_space - def->
offset;
320 r = (
s32) * (coreDump->
zone[i] + offset_in_zone);
323 "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n",
324 space, offset_in_space, r,
325 i, def->
offset, zone_end_offset - 1);
369 if (card->dump_buf ==
NULL)
375 if (card->dump_cur_read ==
NULL)
386 find_dump = card->dump_cur_read;
389 for (find_dump = card->dump_cur_read->next;
390 (find_dump->
count == 0) && (find_dump != card->dump_cur_read);
391 find_dump = card->dump_cur_read->next)
396 for (i = 0, find_dump = card->dump_cur_read;
398 i++, find_dump = find_dump->
prev)
403 "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n",
404 i, find_dump->
count, find_dump, find_dump->
prev,
405 find_dump->
next, card->dump_cur_read, card->dump_buf);
406 if (find_dump->
prev == card->dump_cur_read)
412 "Dump index %d not found %d\n", req->
index, i);
423 if (find_dump->
count == 0)
439 "Can't read space %d, reg 0x%x from coredump buffer %d\n",
508 "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n",
519 unifi_error(card->ospriv,
"Can't read UniFi shared data area\n");
561 r = unifi_coredump_read_zone(card, dump_buf->
zone[i], &zonedef_table[i]);
595 if (dump_buf ==
NULL)
604 sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper);
614 unifi_error(card->ospriv,
"Can't read GBL_CHIP_VERSION\n");
619 dump_buf->
fw_ver = card->build_id;
625 r = unifi_coredump_read_zones(card, dump_buf);
632 unifi_error(card->ospriv,
"Can't read UniFi memory areas\n");
642 #ifndef UNIFI_DISABLE_COREDUMP
679 zone_size =
sizeof(
u16) * zonedef_table[i].
length;
681 newnode->
zone[
i] = newzone;
684 unifi_error(ospriv,
"Out of memory on coredump zone %d (%d words)\n",
685 i, zonedef_table[i].
length);
693 for (i = 0; newnode->
zone[
i] !=
NULL; i++)
701 newnode->
prev = prevnode;
704 prevnode->
next = newnode;
739 #ifndef UNIFI_DISABLE_COREDUMP
740 void *ospriv = card->ospriv;
748 card->request_coredump_on_reset = 0;
749 card->dump_next_write =
NULL;
750 card->dump_cur_read =
NULL;
751 card->dump_buf =
NULL;
753 #ifndef UNIFI_DISABLE_COREDUMP
755 "Allocate buffers for %d core dumps\n", num_dump_buffers);
756 if (num_dump_buffers == 0)
762 card->dump_buf = new_coredump_node(ospriv,
NULL);
763 if (card->dump_buf ==
NULL)
767 prev = card->dump_buf;
768 newnode = card->dump_buf;
771 for (i = 1; i < num_dump_buffers; i++)
773 newnode = new_coredump_node(ospriv, prev);
782 card->dump_buf->prev = newnode;
783 newnode->
next = card->dump_buf;
786 card->dump_next_write = card->dump_buf;
787 card->dump_cur_read =
NULL;
796 #ifndef UNIFI_DISABLE_COREDUMP
799 unifi_error(ospriv,
"Out of memory allocating core dump node %d\n", i);
824 void *ospriv = card->ospriv;
832 if (card->dump_buf ==
NULL)
837 node = card->dump_buf;
854 }
while ((node !=
NULL) && (node != card->dump_buf));
858 card->dump_buf =
NULL;
859 card->dump_next_write =
NULL;
860 card->dump_cur_read =
NULL;