fsp_car.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <config.h>
  6. #include <asm/post.h>
  7. .globl car_init
  8. car_init:
  9. /*
  10. * Note: ebp holds the BIST value (built-in self test) so far, but ebp
  11. * will be destroyed through the FSP call, thus we have to test the
  12. * BIST value here before we call into FSP.
  13. */
  14. test %ebp, %ebp
  15. jz car_init_start
  16. post_code(POST_BIST_FAILURE)
  17. jmp die
  18. car_init_start:
  19. post_code(POST_CAR_START)
  20. lea find_fsp_header_romstack, %esp
  21. jmp find_fsp_header
  22. find_fsp_header_ret:
  23. /* EAX points to FSP_INFO_HEADER */
  24. mov %eax, %ebp
  25. /* sanity test */
  26. cmp $CONFIG_FSP_ADDR, %eax
  27. jb die
  28. /* calculate TempRamInitEntry address */
  29. mov 0x30(%ebp), %eax
  30. add 0x1c(%ebp), %eax
  31. /* call FSP TempRamInitEntry to setup temporary stack */
  32. lea temp_ram_init_romstack, %esp
  33. jmp *%eax
  34. temp_ram_init_ret:
  35. addl $4, %esp
  36. cmp $0, %eax
  37. jnz car_init_fail
  38. post_code(POST_CAR_CPU_CACHE)
  39. /*
  40. * The FSP TempRamInit initializes the ecx and edx registers to
  41. * point to a temporary but writable memory range (Cache-As-RAM).
  42. * ecx: the start of this temporary memory range,
  43. * edx: the end of this range.
  44. */
  45. /* stack grows down from top of CAR */
  46. movl %edx, %esp
  47. subl $4, %esp
  48. xor %esi, %esi
  49. jmp car_init_done
  50. .global fsp_init_done
  51. fsp_init_done:
  52. /*
  53. * We come here from fsp_continue() with eax pointing to the HOB list.
  54. * Save eax to esi temporarily.
  55. */
  56. movl %eax, %esi
  57. car_init_done:
  58. /*
  59. * Re-initialize the ebp (BIST) to zero, as we already reach here
  60. * which means we passed BIST testing before.
  61. */
  62. xorl %ebp, %ebp
  63. jmp car_init_ret
  64. car_init_fail:
  65. post_code(POST_CAR_FAILURE)
  66. die:
  67. hlt
  68. jmp die
  69. hlt
  70. /*
  71. * The function call before CAR initialization is tricky. It cannot
  72. * be called using the 'call' instruction but only the 'jmp' with
  73. * the help of a handcrafted stack in the ROM. The stack needs to
  74. * contain the function return address as well as the parameters.
  75. */
  76. .balign 4
  77. find_fsp_header_romstack:
  78. .long find_fsp_header_ret
  79. .balign 4
  80. temp_ram_init_romstack:
  81. .long temp_ram_init_ret
  82. .long temp_ram_init_params
  83. temp_ram_init_params:
  84. _dt_ucode_base_size:
  85. /* These next two fields are filled in by ifdtool */
  86. .globl ucode_base
  87. ucode_base: /* Declared in microcode.h */
  88. .long 0 /* microcode base */
  89. .globl ucode_size
  90. ucode_size: /* Declared in microcode.h */
  91. .long 0 /* microcode size */
  92. .long CONFIG_SYS_MONITOR_BASE /* code region base */
  93. .long CONFIG_SYS_MONITOR_LEN /* code region size */