1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2007-2010 Red Hat, Inc.
4 * by Peter Jones <pjones@redhat.com>
5 * Copyright 2007 IBM, Inc.
6 * by Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
8 * by Konrad Rzeszutek <ketuzsezr@darnok.org>
10 * This code finds the iSCSI Boot Format Table.
13 #include <linux/memblock.h>
14 #include <linux/blkdev.h>
15 #include <linux/ctype.h>
16 #include <linux/device.h>
17 #include <linux/efi.h>
18 #include <linux/err.h>
19 #include <linux/init.h>
20 #include <linux/limits.h>
21 #include <linux/module.h>
22 #include <linux/pci.h>
23 #include <linux/stat.h>
24 #include <linux/string.h>
25 #include <linux/types.h>
26 #include <linux/acpi.h>
27 #include <linux/iscsi_ibft.h>
29 #include <asm/mmzone.h>
32 * Physical location of iSCSI Boot Format Table.
34 phys_addr_t ibft_phys_addr
;
35 EXPORT_SYMBOL_GPL(ibft_phys_addr
);
41 { "BIFT" }, /* Broadcom iSCSI Offload */
44 #define IBFT_SIGN_LEN 4
45 #define VGA_MEM 0xA0000 /* VGA buffer */
46 #define VGA_SIZE 0x20000 /* 128kB */
49 * Routine used to find and reserve the iSCSI Boot Format Table
51 void __init
reserve_ibft_region(void)
53 unsigned long pos
, virt_pos
= 0;
60 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
61 * only use ACPI for this
63 if (efi_enabled(EFI_BOOT
))
66 for (pos
= IBFT_START
; pos
< IBFT_END
; pos
+= 16) {
67 /* The table can't be inside the VGA BIOS reserved space,
68 * so skip that area */
72 /* Map page by page */
73 if (offset_in_page(pos
) == 0) {
75 early_memunmap(virt
, PAGE_SIZE
);
76 virt
= early_memremap_ro(pos
, PAGE_SIZE
);
80 for (i
= 0; i
< ARRAY_SIZE(ibft_signs
); i
++) {
81 if (memcmp(virt
+ (pos
- virt_pos
), ibft_signs
[i
].sign
,
82 IBFT_SIGN_LEN
) == 0) {
84 (unsigned long *)(virt
+ pos
- virt_pos
+ 4);
86 /* if the length of the table extends past 1M,
87 * the table cannot be valid. */
88 if (pos
+ len
<= (IBFT_END
-1)) {
90 memblock_reserve(ibft_phys_addr
, PAGE_ALIGN(len
));
91 pr_info("iBFT found at %pa.\n", &ibft_phys_addr
);
99 early_memunmap(virt
, PAGE_SIZE
);