6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2013 Joyent, Inc. All rights reserved.
27 */
28
29
30 #include <sys/types.h>
31 #include <sys/machparam.h>
32 #include <sys/x86_archext.h>
33 #include <sys/systm.h>
34 #include <sys/mach_mmu.h>
35 #include <sys/multiboot.h>
36 #include <sys/multiboot2.h>
37 #include <sys/multiboot2_impl.h>
38 #include <sys/sysmacros.h>
39 #include <sys/framebuffer.h>
40 #include <sys/sha1.h>
41 #include <util/string.h>
42 #include <util/strtolctype.h>
43 #include <sys/efi.h>
44
45 /*
46 * Compile time debug knob. We do not have any early mechanism to control it
1742 if (efi64tagp != NULL) {
1743 bi->bi_uefi_arch = XBI_UEFI_ARCH_64;
1744 bi->bi_uefi_systab = (native_ptr_t)(uintptr_t)
1745 efi64tagp->mb_pointer;
1746 process_efi64((EFI_SYSTEM_TABLE64 *)(uintptr_t)
1747 efi64tagp->mb_pointer);
1748 } else {
1749 efi32tagp = (multiboot_tag_efi32_t *)
1750 dboot_multiboot2_find_tag(mb2_info,
1751 MULTIBOOT_TAG_TYPE_EFI32);
1752 if (efi32tagp != NULL) {
1753 bi->bi_uefi_arch = XBI_UEFI_ARCH_32;
1754 bi->bi_uefi_systab = (native_ptr_t)(uintptr_t)
1755 efi32tagp->mb_pointer;
1756 process_efi32((EFI_SYSTEM_TABLE32 *)(uintptr_t)
1757 efi32tagp->mb_pointer);
1758 }
1759 }
1760
1761 /*
1762 * The ACPI RSDP can be found by scanning the BIOS memory areas or
1763 * from the EFI system table. The boot loader may pass in the address
1764 * it found the ACPI tables at.
1765 */
1766 nacpitagp = (multiboot_tag_new_acpi_t *)
1767 dboot_multiboot2_find_tag(mb2_info,
1768 MULTIBOOT_TAG_TYPE_ACPI_NEW);
1769 oacpitagp = (multiboot_tag_old_acpi_t *)
1770 dboot_multiboot2_find_tag(mb2_info,
1771 MULTIBOOT_TAG_TYPE_ACPI_OLD);
1772
1773 if (nacpitagp != NULL) {
1774 bi->bi_acpi_rsdp = (native_ptr_t)(uintptr_t)
1775 &nacpitagp->mb_rsdp[0];
1776 } else if (oacpitagp != NULL) {
1777 bi->bi_acpi_rsdp = (native_ptr_t)(uintptr_t)
1778 &oacpitagp->mb_rsdp[0];
1779 }
1780 }
1781
1782 /* print out EFI version string with newline */
1783 static void
1784 dboot_print_efi_version(uint32_t ver)
1785 {
1786 int rev;
1787
1788 dboot_printf("%d.", EFI_REV_MAJOR(ver));
1789
1790 rev = EFI_REV_MINOR(ver);
1791 if ((rev % 10) != 0) {
1792 dboot_printf("%d.%d\n", rev / 10, rev % 10);
1793 } else {
1794 dboot_printf("%d\n", rev / 10);
1795 }
1796 }
1797
2270
2271 if (bootloader != NULL && prom_debug) {
2272 dboot_printf("Kernel loaded by: %s\n", bootloader);
2273 #if !defined(__xpv)
2274 dboot_printf("Using multiboot %d boot protocol.\n",
2275 multiboot_version);
2276 #endif
2277 }
2278
2279 if (strstr(cmdline, "multiboot") != NULL) {
2280 dboot_panic(NO_MULTIBOOT);
2281 }
2282
2283 DBG((uintptr_t)bi);
2284 #if !defined(__xpv)
2285 DBG((uintptr_t)mb_info);
2286 DBG((uintptr_t)mb2_info);
2287 if (mb2_info != NULL)
2288 DBG(mb2_info->mbi_total_size);
2289 DBG(bi->bi_acpi_rsdp);
2290 DBG(bi->bi_smbios);
2291 DBG(bi->bi_uefi_arch);
2292 DBG(bi->bi_uefi_systab);
2293
2294 if (bi->bi_uefi_systab && prom_debug) {
2295 if (bi->bi_uefi_arch == XBI_UEFI_ARCH_64) {
2296 print_efi64((EFI_SYSTEM_TABLE64 *)(uintptr_t)
2297 bi->bi_uefi_systab);
2298 } else {
2299 print_efi32((EFI_SYSTEM_TABLE32 *)(uintptr_t)
2300 bi->bi_uefi_systab);
2301 }
2302 }
2303 #endif
2304
2305 /*
2306 * Need correct target_kernel_text value
2307 */
2308 #if defined(_BOOT_TARGET_amd64)
2309 target_kernel_text = KERNEL_TEXT_amd64;
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2020 Joyent, Inc.
27 */
28
29
30 #include <sys/types.h>
31 #include <sys/machparam.h>
32 #include <sys/x86_archext.h>
33 #include <sys/systm.h>
34 #include <sys/mach_mmu.h>
35 #include <sys/multiboot.h>
36 #include <sys/multiboot2.h>
37 #include <sys/multiboot2_impl.h>
38 #include <sys/sysmacros.h>
39 #include <sys/framebuffer.h>
40 #include <sys/sha1.h>
41 #include <util/string.h>
42 #include <util/strtolctype.h>
43 #include <sys/efi.h>
44
45 /*
46 * Compile time debug knob. We do not have any early mechanism to control it
1742 if (efi64tagp != NULL) {
1743 bi->bi_uefi_arch = XBI_UEFI_ARCH_64;
1744 bi->bi_uefi_systab = (native_ptr_t)(uintptr_t)
1745 efi64tagp->mb_pointer;
1746 process_efi64((EFI_SYSTEM_TABLE64 *)(uintptr_t)
1747 efi64tagp->mb_pointer);
1748 } else {
1749 efi32tagp = (multiboot_tag_efi32_t *)
1750 dboot_multiboot2_find_tag(mb2_info,
1751 MULTIBOOT_TAG_TYPE_EFI32);
1752 if (efi32tagp != NULL) {
1753 bi->bi_uefi_arch = XBI_UEFI_ARCH_32;
1754 bi->bi_uefi_systab = (native_ptr_t)(uintptr_t)
1755 efi32tagp->mb_pointer;
1756 process_efi32((EFI_SYSTEM_TABLE32 *)(uintptr_t)
1757 efi32tagp->mb_pointer);
1758 }
1759 }
1760
1761 /*
1762 * The multiboot2 info contains a copy of the RSDP; stash a pointer to
1763 * it (see find_rsdp() in fakebop).
1764 */
1765 nacpitagp = (multiboot_tag_new_acpi_t *)
1766 dboot_multiboot2_find_tag(mb2_info, MULTIBOOT_TAG_TYPE_ACPI_NEW);
1767 oacpitagp = (multiboot_tag_old_acpi_t *)
1768 dboot_multiboot2_find_tag(mb2_info, MULTIBOOT_TAG_TYPE_ACPI_OLD);
1769
1770 if (nacpitagp != NULL) {
1771 bi->bi_acpi_rsdp_copy = (native_ptr_t)(uintptr_t)
1772 &nacpitagp->mb_rsdp[0];
1773 } else if (oacpitagp != NULL) {
1774 bi->bi_acpi_rsdp_copy = (native_ptr_t)(uintptr_t)
1775 &oacpitagp->mb_rsdp[0];
1776 }
1777 }
1778
1779 /* print out EFI version string with newline */
1780 static void
1781 dboot_print_efi_version(uint32_t ver)
1782 {
1783 int rev;
1784
1785 dboot_printf("%d.", EFI_REV_MAJOR(ver));
1786
1787 rev = EFI_REV_MINOR(ver);
1788 if ((rev % 10) != 0) {
1789 dboot_printf("%d.%d\n", rev / 10, rev % 10);
1790 } else {
1791 dboot_printf("%d\n", rev / 10);
1792 }
1793 }
1794
2267
2268 if (bootloader != NULL && prom_debug) {
2269 dboot_printf("Kernel loaded by: %s\n", bootloader);
2270 #if !defined(__xpv)
2271 dboot_printf("Using multiboot %d boot protocol.\n",
2272 multiboot_version);
2273 #endif
2274 }
2275
2276 if (strstr(cmdline, "multiboot") != NULL) {
2277 dboot_panic(NO_MULTIBOOT);
2278 }
2279
2280 DBG((uintptr_t)bi);
2281 #if !defined(__xpv)
2282 DBG((uintptr_t)mb_info);
2283 DBG((uintptr_t)mb2_info);
2284 if (mb2_info != NULL)
2285 DBG(mb2_info->mbi_total_size);
2286 DBG(bi->bi_acpi_rsdp);
2287 DBG(bi->bi_acpi_rsdp_copy);
2288 DBG(bi->bi_smbios);
2289 DBG(bi->bi_uefi_arch);
2290 DBG(bi->bi_uefi_systab);
2291
2292 if (bi->bi_uefi_systab && prom_debug) {
2293 if (bi->bi_uefi_arch == XBI_UEFI_ARCH_64) {
2294 print_efi64((EFI_SYSTEM_TABLE64 *)(uintptr_t)
2295 bi->bi_uefi_systab);
2296 } else {
2297 print_efi32((EFI_SYSTEM_TABLE32 *)(uintptr_t)
2298 bi->bi_uefi_systab);
2299 }
2300 }
2301 #endif
2302
2303 /*
2304 * Need correct target_kernel_text value
2305 */
2306 #if defined(_BOOT_TARGET_amd64)
2307 target_kernel_text = KERNEL_TEXT_amd64;
|