fsp_car.S 2.4 KB

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