Linux Audio

Check our new training course

Loading...
v5.9
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  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>
  7 *  Copyright 2008
  8 *  by Konrad Rzeszutek <ketuzsezr@darnok.org>
  9 *
 10 * This code finds the iSCSI Boot Format Table.
 
 
 
 
 
 
 
 
 
 11 */
 12
 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>
 28
 29#include <asm/mmzone.h>
 30
 31/*
 32 * Physical location of iSCSI Boot Format Table.
 33 */
 34struct acpi_table_ibft *ibft_addr;
 35EXPORT_SYMBOL_GPL(ibft_addr);
 36
 37static const struct {
 38	char *sign;
 39} ibft_signs[] = {
 
 
 
 
 
 
 
 40	{ "iBFT" },
 41	{ "BIFT" },	/* Broadcom iSCSI Offload */
 42};
 43
 44#define IBFT_SIGN_LEN 4
 45#define IBFT_START 0x80000 /* 512kB */
 46#define IBFT_END 0x100000 /* 1MB */
 47#define VGA_MEM 0xA0000 /* VGA buffer */
 48#define VGA_SIZE 0x20000 /* 128kB */
 49
 
 
 
 
 
 
 
 
 50static int __init find_ibft_in_mem(void)
 51{
 52	unsigned long pos;
 53	unsigned int len = 0;
 54	void *virt;
 55	int i;
 56
 57	for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
 58		/* The table can't be inside the VGA BIOS reserved space,
 59		 * so skip that area */
 60		if (pos == VGA_MEM)
 61			pos += VGA_SIZE;
 62		virt = isa_bus_to_virt(pos);
 63
 64		for (i = 0; i < ARRAY_SIZE(ibft_signs); i++) {
 65			if (memcmp(virt, ibft_signs[i].sign, IBFT_SIGN_LEN) ==
 66			    0) {
 67				unsigned long *addr =
 68				    (unsigned long *)isa_bus_to_virt(pos + 4);
 69				len = *addr;
 70				/* if the length of the table extends past 1M,
 71				 * the table cannot be valid. */
 72				if (pos + len <= (IBFT_END-1)) {
 73					ibft_addr = (struct acpi_table_ibft *)virt;
 74					pr_info("iBFT found at 0x%lx.\n", pos);
 75					goto done;
 76				}
 77			}
 78		}
 79	}
 80done:
 81	return len;
 82}
 83/*
 84 * Routine used to find the iSCSI Boot Format Table. The logical
 85 * kernel address is set in the ibft_addr global variable.
 86 */
 87unsigned long __init find_ibft_region(unsigned long *sizep)
 88{
 
 
 
 89	ibft_addr = NULL;
 90
 
 
 
 
 
 91	/* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
 92	 * only use ACPI for this */
 93
 94	if (!efi_enabled(EFI_BOOT))
 95		find_ibft_in_mem();
 96
 97	if (ibft_addr) {
 98		*sizep = PAGE_ALIGN(ibft_addr->header.length);
 99		return (u64)virt_to_phys(ibft_addr);
100	}
101
102	*sizep = 0;
103	return 0;
104}
v3.1
 
  1/*
  2 *  Copyright 2007-2010 Red Hat, Inc.
  3 *  by Peter Jones <pjones@redhat.com>
  4 *  Copyright 2007 IBM, Inc.
  5 *  by Konrad Rzeszutek <konradr@linux.vnet.ibm.com>
  6 *  Copyright 2008
  7 *  by Konrad Rzeszutek <ketuzsezr@darnok.org>
  8 *
  9 * This code finds the iSCSI Boot Format Table.
 10 *
 11 * This program is free software; you can redistribute it and/or modify
 12 * it under the terms of the GNU General Public License v2.0 as published by
 13 * the Free Software Foundation
 14 *
 15 * This program is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18 * GNU General Public License for more details.
 19 */
 20
 21#include <linux/bootmem.h>
 22#include <linux/blkdev.h>
 23#include <linux/ctype.h>
 24#include <linux/device.h>
 25#include <linux/efi.h>
 26#include <linux/err.h>
 27#include <linux/init.h>
 28#include <linux/limits.h>
 29#include <linux/module.h>
 30#include <linux/pci.h>
 31#include <linux/stat.h>
 32#include <linux/string.h>
 33#include <linux/types.h>
 34#include <linux/acpi.h>
 35#include <linux/iscsi_ibft.h>
 36
 37#include <asm/mmzone.h>
 38
 39/*
 40 * Physical location of iSCSI Boot Format Table.
 41 */
 42struct acpi_table_ibft *ibft_addr;
 43EXPORT_SYMBOL_GPL(ibft_addr);
 44
 45static const struct {
 46	char *sign;
 47} ibft_signs[] = {
 48#ifdef CONFIG_ACPI
 49	/*
 50	 * One spec says "IBFT", the other says "iBFT". We have to check
 51	 * for both.
 52	 */
 53	{ ACPI_SIG_IBFT },
 54#endif
 55	{ "iBFT" },
 56	{ "BIFT" },	/* Broadcom iSCSI Offload */
 57};
 58
 59#define IBFT_SIGN_LEN 4
 60#define IBFT_START 0x80000 /* 512kB */
 61#define IBFT_END 0x100000 /* 1MB */
 62#define VGA_MEM 0xA0000 /* VGA buffer */
 63#define VGA_SIZE 0x20000 /* 128kB */
 64
 65#ifdef CONFIG_ACPI
 66static int __init acpi_find_ibft(struct acpi_table_header *header)
 67{
 68	ibft_addr = (struct acpi_table_ibft *)header;
 69	return 0;
 70}
 71#endif /* CONFIG_ACPI */
 72
 73static int __init find_ibft_in_mem(void)
 74{
 75	unsigned long pos;
 76	unsigned int len = 0;
 77	void *virt;
 78	int i;
 79
 80	for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
 81		/* The table can't be inside the VGA BIOS reserved space,
 82		 * so skip that area */
 83		if (pos == VGA_MEM)
 84			pos += VGA_SIZE;
 85		virt = isa_bus_to_virt(pos);
 86
 87		for (i = 0; i < ARRAY_SIZE(ibft_signs); i++) {
 88			if (memcmp(virt, ibft_signs[i].sign, IBFT_SIGN_LEN) ==
 89			    0) {
 90				unsigned long *addr =
 91				    (unsigned long *)isa_bus_to_virt(pos + 4);
 92				len = *addr;
 93				/* if the length of the table extends past 1M,
 94				 * the table cannot be valid. */
 95				if (pos + len <= (IBFT_END-1)) {
 96					ibft_addr = (struct acpi_table_ibft *)virt;
 
 97					goto done;
 98				}
 99			}
100		}
101	}
102done:
103	return len;
104}
105/*
106 * Routine used to find the iSCSI Boot Format Table. The logical
107 * kernel address is set in the ibft_addr global variable.
108 */
109unsigned long __init find_ibft_region(unsigned long *sizep)
110{
111#ifdef CONFIG_ACPI
112	int i;
113#endif
114	ibft_addr = NULL;
115
116#ifdef CONFIG_ACPI
117	for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++)
118		acpi_table_parse(ibft_signs[i].sign, acpi_find_ibft);
119#endif /* CONFIG_ACPI */
120
121	/* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
122	 * only use ACPI for this */
123
124	if (!ibft_addr && !efi_enabled)
125		find_ibft_in_mem();
126
127	if (ibft_addr) {
128		*sizep = PAGE_ALIGN(ibft_addr->header.length);
129		return (u64)isa_virt_to_bus(ibft_addr);
130	}
131
132	*sizep = 0;
133	return 0;
134}