| 588 | } |
| 589 | |
| 590 | static int |
| 591 | dbg_setup_xpoint(struct dbg_wb_conf *conf) |
| 592 | { |
| 593 | struct pcpu *pcpu; |
| 594 | struct dbreg *d; |
| 595 | const char *typestr; |
| 596 | uint32_t cr_size, cr_priv, cr_access; |
| 597 | uint32_t reg_ctrl, reg_addr, ctrl, addr; |
| 598 | boolean_t is_bkpt; |
| 599 | u_int cpu; |
| 600 | u_int i; |
| 601 | |
| 602 | if (!dbg_capable()) |
| 603 | return (ENXIO); |
| 604 | |
| 605 | is_bkpt = (conf->type == DBG_TYPE_BREAKPOINT); |
| 606 | typestr = is_bkpt ? "breakpoint" : "watchpoint"; |
| 607 | |
| 608 | if (is_bkpt) { |
| 609 | if (dbg_breakpoint_num == 0) { |
| 610 | db_printf("Breakpoints not supported on this architecture\n"); |
| 611 | return (ENXIO); |
| 612 | } |
| 613 | i = conf->slot; |
| 614 | if (!dbg_check_slot_free(DBG_TYPE_BREAKPOINT, i)) { |
| 615 | /* |
| 616 | * This should never happen. If it does it means that |
| 617 | * there is an erroneus scenario somewhere. Still, it can |
| 618 | * be done but let's inform the user. |
| 619 | */ |
| 620 | db_printf("ERROR: Breakpoint already set. Replacing...\n"); |
| 621 | } |
| 622 | } else { |
| 623 | i = dbg_find_free_slot(DBG_TYPE_WATCHPOINT); |
| 624 | if (i == ~0U) { |
| 625 | db_printf("Can not find slot for %s, max %d slots supported\n", |
| 626 | typestr, dbg_watchpoint_num); |
| 627 | return (ENXIO); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /* Kernel access only */ |
| 632 | cr_priv = DBG_WB_CTRL_PL1; |
| 633 | |
| 634 | switch(conf->size) { |
| 635 | case 1: |
| 636 | cr_size = DBG_WB_CTRL_LEN_1; |
| 637 | break; |
| 638 | case 2: |
| 639 | cr_size = DBG_WB_CTRL_LEN_2; |
| 640 | break; |
| 641 | case 4: |
| 642 | cr_size = DBG_WB_CTRL_LEN_4; |
| 643 | break; |
| 644 | case 8: |
| 645 | cr_size = DBG_WB_CTRL_LEN_8; |
| 646 | break; |
| 647 | default: |
no test coverage detected