Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

169 lines
3.6 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
  4. */
  5. #include <common.h>
  6. #include <asm/arcregs.h>
  7. #include <asm/ptrace.h>
  8. /* Bit values in STATUS32 */
  9. #define E1_MASK (1 << 1) /* Level 1 interrupts enable */
  10. #define E2_MASK (1 << 2) /* Level 2 interrupts enable */
  11. int interrupt_init(void)
  12. {
  13. return 0;
  14. }
  15. /*
  16. * returns true if interrupts had been enabled before we disabled them
  17. */
  18. int disable_interrupts(void)
  19. {
  20. int status = read_aux_reg(ARC_AUX_STATUS32);
  21. int state = (status & (E1_MASK | E2_MASK)) ? 1 : 0;
  22. status &= ~(E1_MASK | E2_MASK);
  23. /* STATUS32 register is updated indirectly with "FLAG" instruction */
  24. __asm__("flag %0" : : "r" (status));
  25. return state;
  26. }
  27. void enable_interrupts(void)
  28. {
  29. unsigned int status = read_aux_reg(ARC_AUX_STATUS32);
  30. status |= E1_MASK | E2_MASK;
  31. /* STATUS32 register is updated indirectly with "FLAG" instruction */
  32. __asm__("flag %0" : : "r" (status));
  33. }
  34. static void print_reg_file(long *reg_rev, int start_num)
  35. {
  36. unsigned int i;
  37. /* Print 3 registers per line */
  38. for (i = start_num; i < start_num + 25; i++) {
  39. printf("r%02u: 0x%08lx\t", i, (unsigned long)*reg_rev);
  40. if (((i + 1) % 3) == 0)
  41. printf("\n");
  42. /* Because pt_regs has registers reversed */
  43. reg_rev--;
  44. }
  45. /* Add new-line if none was inserted in the end of loop above */
  46. if (((i + 1) % 3) != 0)
  47. printf("\n");
  48. }
  49. void show_regs(struct pt_regs *regs)
  50. {
  51. printf("ECR:\t0x%08lx\n", regs->ecr);
  52. printf("RET:\t0x%08lx\nBLINK:\t0x%08lx\nSTAT32:\t0x%08lx\n",
  53. regs->ret, regs->blink, regs->status32);
  54. printf("GP: 0x%08lx\t r25: 0x%08lx\t\n", regs->r26, regs->r25);
  55. printf("BTA: 0x%08lx\t SP: 0x%08lx\t FP: 0x%08lx\n", regs->bta,
  56. regs->sp, regs->fp);
  57. printf("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n", regs->lp_start,
  58. regs->lp_end, regs->lp_count);
  59. print_reg_file(&(regs->r0), 0);
  60. }
  61. void bad_mode(struct pt_regs *regs)
  62. {
  63. if (regs)
  64. show_regs(regs);
  65. panic("Resetting CPU ...\n");
  66. }
  67. void do_memory_error(unsigned long address, struct pt_regs *regs)
  68. {
  69. printf("Memory error exception @ 0x%lx\n", address);
  70. bad_mode(regs);
  71. }
  72. void do_instruction_error(unsigned long address, struct pt_regs *regs)
  73. {
  74. printf("Instruction error exception @ 0x%lx\n", address);
  75. bad_mode(regs);
  76. }
  77. void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
  78. {
  79. printf("Machine check exception @ 0x%lx\n", address);
  80. bad_mode(regs);
  81. }
  82. void do_interrupt_handler(void)
  83. {
  84. printf("Interrupt fired\n");
  85. bad_mode(0);
  86. }
  87. void do_itlb_miss(struct pt_regs *regs)
  88. {
  89. printf("I TLB miss exception\n");
  90. bad_mode(regs);
  91. }
  92. void do_dtlb_miss(struct pt_regs *regs)
  93. {
  94. printf("D TLB miss exception\n");
  95. bad_mode(regs);
  96. }
  97. void do_tlb_prot_violation(unsigned long address, struct pt_regs *regs)
  98. {
  99. printf("TLB protection violation or misaligned access @ 0x%lx\n",
  100. address);
  101. bad_mode(regs);
  102. }
  103. void do_privilege_violation(struct pt_regs *regs)
  104. {
  105. printf("Privilege violation exception\n");
  106. bad_mode(regs);
  107. }
  108. void do_trap(struct pt_regs *regs)
  109. {
  110. printf("Trap exception\n");
  111. bad_mode(regs);
  112. }
  113. void do_extension(struct pt_regs *regs)
  114. {
  115. printf("Extension instruction exception\n");
  116. bad_mode(regs);
  117. }
  118. #ifdef CONFIG_ISA_ARCV2
  119. void do_swi(struct pt_regs *regs)
  120. {
  121. printf("Software Interrupt exception\n");
  122. bad_mode(regs);
  123. }
  124. void do_divzero(unsigned long address, struct pt_regs *regs)
  125. {
  126. printf("Division by zero exception @ 0x%lx\n", address);
  127. bad_mode(regs);
  128. }
  129. void do_dcerror(struct pt_regs *regs)
  130. {
  131. printf("Data cache consistency error exception\n");
  132. bad_mode(regs);
  133. }
  134. void do_maligned(unsigned long address, struct pt_regs *regs)
  135. {
  136. printf("Misaligned data access exception @ 0x%lx\n", address);
  137. bad_mode(regs);
  138. }
  139. #endif