elf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* MN10300 ELF constant and register definitions
  2. *
  3. * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
  4. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells (dhowells@redhat.com)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public Licence
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the Licence, or (at your option) any later version.
  11. */
  12. #ifndef _ASM_ELF_H
  13. #define _ASM_ELF_H
  14. #include <linux/utsname.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/user.h>
  17. /*
  18. * AM33 relocations
  19. */
  20. #define R_MN10300_NONE 0 /* No reloc. */
  21. #define R_MN10300_32 1 /* Direct 32 bit. */
  22. #define R_MN10300_16 2 /* Direct 16 bit. */
  23. #define R_MN10300_8 3 /* Direct 8 bit. */
  24. #define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */
  25. #define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */
  26. #define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */
  27. #define R_MN10300_24 9 /* Direct 24 bit. */
  28. #define R_MN10300_RELATIVE 23 /* Adjust by program base. */
  29. #define R_MN10300_SYM_DIFF 33 /* Adjustment when relaxing. */
  30. #define R_MN10300_ALIGN 34 /* Alignment requirement. */
  31. /*
  32. * AM33/AM34 HW Capabilities
  33. */
  34. #define HWCAP_MN10300_ATOMIC_OP_UNIT 1 /* Has AM34 Atomic Operations */
  35. /*
  36. * ELF register definitions..
  37. */
  38. typedef unsigned long elf_greg_t;
  39. #define ELF_NGREG ((sizeof(struct pt_regs) / sizeof(elf_greg_t)) - 1)
  40. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  41. #define ELF_NFPREG 32
  42. typedef float elf_fpreg_t;
  43. typedef struct {
  44. elf_fpreg_t fpregs[ELF_NFPREG];
  45. u_int32_t fpcr;
  46. } elf_fpregset_t;
  47. /*
  48. * This is used to ensure we don't load something for the wrong architecture
  49. */
  50. #define elf_check_arch(x) \
  51. (((x)->e_machine == EM_CYGNUS_MN10300) || \
  52. ((x)->e_machine == EM_MN10300))
  53. /*
  54. * These are used to set parameters in the core dumps.
  55. */
  56. #define ELF_CLASS ELFCLASS32
  57. #define ELF_DATA ELFDATA2LSB
  58. #define ELF_ARCH EM_MN10300
  59. /*
  60. * ELF process initialiser
  61. */
  62. #define ELF_PLAT_INIT(_r, load_addr) \
  63. do { \
  64. struct pt_regs *_ur = current->thread.uregs; \
  65. _ur->a3 = 0; _ur->a2 = 0; _ur->d3 = 0; _ur->d2 = 0; \
  66. _ur->mcvf = 0; _ur->mcrl = 0; _ur->mcrh = 0; _ur->mdrq = 0; \
  67. _ur->e1 = 0; _ur->e0 = 0; _ur->e7 = 0; _ur->e6 = 0; \
  68. _ur->e5 = 0; _ur->e4 = 0; _ur->e3 = 0; _ur->e2 = 0; \
  69. _ur->lar = 0; _ur->lir = 0; _ur->mdr = 0; \
  70. _ur->a1 = 0; _ur->a0 = 0; _ur->d1 = 0; _ur->d0 = 0; \
  71. } while (0)
  72. #define CORE_DUMP_USE_REGSET
  73. #define ELF_EXEC_PAGESIZE 4096
  74. /*
  75. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  76. * use of this is to invoke "./ld.so someprog" to test out a new version of
  77. * the loader. We need to make sure that it is out of the way of the program
  78. * that it will "exec", and that there is sufficient room for the brk.
  79. * - must clear the VMALLOC area
  80. */
  81. #define ELF_ET_DYN_BASE 0x04000000
  82. /*
  83. * regs is struct pt_regs, pr_reg is elf_gregset_t (which is
  84. * now struct user_regs, they are different)
  85. * - ELF_CORE_COPY_REGS has been guessed, and may be wrong
  86. */
  87. #define ELF_CORE_COPY_REGS(pr_reg, regs) \
  88. do { \
  89. pr_reg[0] = regs->a3; \
  90. pr_reg[1] = regs->a2; \
  91. pr_reg[2] = regs->d3; \
  92. pr_reg[3] = regs->d2; \
  93. pr_reg[4] = regs->mcvf; \
  94. pr_reg[5] = regs->mcrl; \
  95. pr_reg[6] = regs->mcrh; \
  96. pr_reg[7] = regs->mdrq; \
  97. pr_reg[8] = regs->e1; \
  98. pr_reg[9] = regs->e0; \
  99. pr_reg[10] = regs->e7; \
  100. pr_reg[11] = regs->e6; \
  101. pr_reg[12] = regs->e5; \
  102. pr_reg[13] = regs->e4; \
  103. pr_reg[14] = regs->e3; \
  104. pr_reg[15] = regs->e2; \
  105. pr_reg[16] = regs->sp; \
  106. pr_reg[17] = regs->lar; \
  107. pr_reg[18] = regs->lir; \
  108. pr_reg[19] = regs->mdr; \
  109. pr_reg[20] = regs->a1; \
  110. pr_reg[21] = regs->a0; \
  111. pr_reg[22] = regs->d1; \
  112. pr_reg[23] = regs->d0; \
  113. pr_reg[24] = regs->orig_d0; \
  114. pr_reg[25] = regs->epsw; \
  115. pr_reg[26] = regs->pc; \
  116. } while (0);
  117. /*
  118. * This yields a mask that user programs can use to figure out what
  119. * instruction set this CPU supports. This could be done in user space,
  120. * but it's not easy, and we've already done it here.
  121. */
  122. #ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
  123. #define ELF_HWCAP (HWCAP_MN10300_ATOMIC_OP_UNIT)
  124. #else
  125. #define ELF_HWCAP (0)
  126. #endif
  127. /*
  128. * This yields a string that ld.so will use to load implementation
  129. * specific libraries for optimization. This is more specific in
  130. * intent than poking at uname or /proc/cpuinfo.
  131. *
  132. * For the moment, we have only optimizations for the Intel generations,
  133. * but that could change...
  134. */
  135. #define ELF_PLATFORM (NULL)
  136. #endif /* _ASM_ELF_H */