coreboot.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * (C) Copyright 2008
  4. * Graeme Russ, graeme.russ@gmail.com.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/u-boot-x86.h>
  10. #include <flash.h>
  11. #include <netdev.h>
  12. #include <ns16550.h>
  13. #include <asm/msr.h>
  14. #include <asm/cache.h>
  15. #include <asm/cpu.h>
  16. #include <asm/io.h>
  17. #include <asm/mtrr.h>
  18. #include <asm/arch/tables.h>
  19. #include <asm/arch/sysinfo.h>
  20. #include <asm/arch/timestamp.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. int arch_cpu_init(void)
  23. {
  24. int ret = get_coreboot_info(&lib_sysinfo);
  25. if (ret != 0) {
  26. printf("Failed to parse coreboot tables.\n");
  27. return ret;
  28. }
  29. timestamp_init();
  30. return x86_cpu_init_f();
  31. }
  32. int board_early_init_f(void)
  33. {
  34. return 0;
  35. }
  36. int print_cpuinfo(void)
  37. {
  38. return default_print_cpuinfo();
  39. }
  40. int last_stage_init(void)
  41. {
  42. if (gd->flags & GD_FLG_COLD_BOOT)
  43. timestamp_add_to_bootstage();
  44. return 0;
  45. }
  46. #ifndef CONFIG_SYS_NO_FLASH
  47. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  48. {
  49. return 0;
  50. }
  51. #endif
  52. int board_eth_init(bd_t *bis)
  53. {
  54. return pci_eth_init(bis);
  55. }
  56. void board_final_cleanup(void)
  57. {
  58. /* Un-cache the ROM so the kernel has one
  59. * more MTRR available.
  60. *
  61. * Coreboot should have assigned this to the
  62. * top available variable MTRR.
  63. */
  64. u8 top_mtrr = (native_read_msr(MTRR_CAP_MSR) & 0xff) - 1;
  65. u8 top_type = native_read_msr(MTRR_PHYS_BASE_MSR(top_mtrr)) & 0xff;
  66. /* Make sure this MTRR is the correct Write-Protected type */
  67. if (top_type == MTRR_TYPE_WRPROT) {
  68. struct mtrr_state state;
  69. mtrr_open(&state);
  70. wrmsrl(MTRR_PHYS_BASE_MSR(top_mtrr), 0);
  71. wrmsrl(MTRR_PHYS_MASK_MSR(top_mtrr), 0);
  72. mtrr_close(&state);
  73. }
  74. /* Issue SMI to Coreboot to lock down ME and registers */
  75. printf("Finalizing Coreboot\n");
  76. outb(0xcb, 0xb2);
  77. }
  78. void panic_puts(const char *str)
  79. {
  80. NS16550_t port = (NS16550_t)0x3f8;
  81. NS16550_init(port, 1);
  82. while (*str)
  83. NS16550_putc(port, *str++);
  84. }
  85. int misc_init_r(void)
  86. {
  87. return 0;
  88. }