home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / gdb / sparcl-tdep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-10  |  5.0 KB  |  211 lines

  1. /* Target-dependent code for the Fujitsu SPARCLITE for GDB, the GNU debugger.
  2.    Copyright 1994  Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "defs.h"
  21. #include "gdbcore.h"
  22. #include "breakpoint.h"
  23.  
  24. #define DDA2_SUP_ASI        0xb000000
  25. #define DDA1_SUP_ASI        0xb0000
  26.  
  27. #define DDA2_ASI_MASK         0xff000000
  28. #define DDA1_ASI_MASK         0xff0000 
  29. #define DIA2_SUP_MODE         0x8000
  30. #define DIA1_SUP_MODE         0x4000
  31. #define DDA2_ENABLE         0x100
  32. #define DDA1_ENABLE         0x80
  33. #define DIA2_ENABLE         0x40
  34. #define DIA1_ENABLE         0x20
  35. #define DSINGLE_STEP         0x10
  36. #define DDV_TYPE_MASK         0xc
  37. #define DDV_TYPE_LOAD         0x0
  38. #define DDV_TYPE_STORE         0x4
  39. #define DDV_TYPE_ACCESS     0x8
  40. #define DDV_TYPE_ALWAYS        0xc
  41. #define DDV_COND        0x2
  42. #define DDV_MASK        0x1
  43.  
  44. int
  45. sparclite_insert_watchpoint(addr, len, type)
  46.     CORE_ADDR addr;
  47.     int len;
  48.     int type;
  49. {
  50. CORE_ADDR dcr;
  51.  
  52.   dcr = read_register (DCR_REGNUM);
  53.  
  54.   if (!(dcr & DDA1_ENABLE))
  55.   {
  56.     write_register (DDA1_REGNUM, addr);
  57.     dcr &= ~(DDA1_ASI_MASK | DDV_TYPE_MASK);
  58.     dcr |= (DDA1_SUP_ASI | DDA1_ENABLE);
  59.     if (type == 1)
  60.     {
  61.       write_register (DDV1_REGNUM, 0);
  62.       write_register (DDV2_REGNUM, 0xffffffff);
  63.       dcr |= (DDV_TYPE_LOAD & (~DDV_COND & ~DDV_MASK));
  64.     }   
  65.     else if (type == 0)
  66.     {
  67.       write_register (DDV1_REGNUM, 0);
  68.       write_register (DDV2_REGNUM, 0xffffffff);
  69.       dcr |= (DDV_TYPE_STORE & (~DDV_COND & ~DDV_MASK));
  70.     }
  71.     else
  72.     {
  73.       write_register (DDV1_REGNUM, 0);
  74.       write_register (DDV2_REGNUM, 0xffffffff);
  75.       dcr |= (DDV_TYPE_ACCESS);
  76.     }
  77.     write_register (DCR_REGNUM, dcr);
  78.   }
  79.   else if (!(dcr & DDA2_ENABLE))
  80.   {
  81.     write_register (DDA2_REGNUM, addr);
  82.     dcr &= ~(DDA2_ASI_MASK & DDV_TYPE_MASK);
  83.     dcr |= (DDA2_SUP_ASI | DDA2_ENABLE);
  84.     if (type == 1)
  85.     {
  86.       write_register (DDV1_REGNUM, 0);
  87.       write_register (DDV2_REGNUM, 0xffffffff);
  88.       dcr |= (DDV_TYPE_LOAD & ~DDV_COND & ~DDV_MASK);
  89.     }
  90.     else if (type == 0)
  91.     {
  92.       write_register (DDV1_REGNUM, 0);
  93.       write_register (DDV2_REGNUM, 0xffffffff);
  94.       dcr |= (DDV_TYPE_STORE & ~DDV_COND & ~DDV_MASK);
  95.     }
  96.     else
  97.     {
  98.       write_register (DDV1_REGNUM, 0);
  99.       write_register (DDV2_REGNUM, 0xffffffff);
  100.       dcr |= (DDV_TYPE_ACCESS);
  101.     }
  102.     write_register (DCR_REGNUM, dcr);
  103.   }
  104.   else
  105.     return -1;
  106.  
  107.   return 0;
  108.  
  109. int
  110. sparclite_remove_watchpoint(addr, len, type)
  111.     CORE_ADDR addr;
  112.     int len;
  113.     int type;
  114. {
  115. CORE_ADDR dcr, dda1, dda2;
  116.  
  117.   dcr = read_register (DCR_REGNUM);
  118.   dda1 = read_register (DDA1_REGNUM);
  119.   dda2 = read_register (DDA2_REGNUM);
  120.  
  121.   if ((dcr & DDA1_ENABLE) && addr == dda1) {
  122.     write_register (DCR_REGNUM, (dcr & ~DDA1_ENABLE));
  123.   }
  124.   else if ((dcr & DDA2_ENABLE) && addr == dda2) {
  125.     write_register (DCR_REGNUM, (dcr & ~DDA2_ENABLE));
  126.   }
  127.   else
  128.     return -1;
  129.  
  130.   return 0;
  131. }
  132.  
  133. int
  134. sparclite_insert_hw_breakpoint(addr, len)
  135.     CORE_ADDR addr;
  136.     int len;
  137. {
  138. CORE_ADDR dcr;
  139.  
  140.   dcr = read_register (DCR_REGNUM);
  141.   
  142.   if (!(dcr & DIA1_ENABLE)) {
  143.     write_register (DIA1_REGNUM, addr);
  144.     write_register (DCR_REGNUM, (dcr | DIA1_ENABLE | DIA1_SUP_MODE));
  145.   }
  146.   else if (!(dcr & DIA2_ENABLE)) {
  147.     write_register (DIA2_REGNUM, addr);
  148.     write_register (DCR_REGNUM, (dcr | DIA2_ENABLE | DIA2_SUP_MODE));
  149.   }
  150.   else
  151.     return -1;
  152.  
  153.   return 0;
  154. }
  155.  
  156. int
  157. sparclite_remove_hw_breakpoint(addr, shadow)
  158.     CORE_ADDR addr;
  159.     int shadow;
  160. {
  161. CORE_ADDR dcr, dia1, dia2;
  162.  
  163.   dcr = read_register (DCR_REGNUM);
  164.   dia1 = read_register (DIA1_REGNUM);
  165.   dia2 = read_register (DIA2_REGNUM);
  166.   
  167.   if ((dcr & DIA1_ENABLE) && addr == dia1) {
  168.     write_register (DCR_REGNUM, (dcr & ~DIA1_ENABLE));
  169.   }
  170.   else if ((dcr & DIA2_ENABLE) && addr == dia2) {
  171.     write_register (DCR_REGNUM, (dcr & ~DIA2_ENABLE));
  172.   }
  173.   else
  174.     return -1;
  175.    
  176.   return 0;
  177. }
  178.  
  179. int
  180. sparclite_check_watch_resources(type, cnt, ot)
  181.     int type;
  182.     int cnt;
  183.     int ot;
  184. {
  185.   if (type == bp_hardware_breakpoint) {
  186.     if (TARGET_HW_BREAK_LIMIT == 0) return 0;
  187.     else if (cnt <= TARGET_HW_BREAK_LIMIT) return 1;
  188.   }
  189.   else {
  190.     if (TARGET_HW_WATCH_LIMIT == 0) return 0;
  191.     else if (ot) return -1;
  192.     else if (cnt <= TARGET_HW_WATCH_LIMIT) return 1;
  193.   }
  194.   return -1;
  195. }
  196.  
  197. CORE_ADDR
  198. sparclite_stopped_data_address()
  199. {
  200.   CORE_ADDR dsr, dda1, dda2;
  201.  
  202.   dsr = read_register (DSR_REGNUM);
  203.   dda1 = read_register (DDA1_REGNUM);
  204.   dda2 = read_register (DDA2_REGNUM);
  205.  
  206.   if (dsr & 0x10) return dda1;
  207.   else if (dsr & 0x20) return dda2;
  208.   else return 0;
  209. }
  210.