2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <dev/isci/isci.h>
39 #include <machine/vmparam.h>
40 #include <machine/pc/bios.h>
41 #include <dev/isci/scil/scu_bios_definitions.h>
49 uint16_t struct_length;
50 uint8_t struct_revision;
54 uint16_t image_length;
55 uint16_t code_revision;
63 uint8_t signature_byte[2];
66 uint16_t entry_address;
67 uint8_t reserved[0x12];
68 uint16_t pcir_pointer;
72 struct oem_parameters_table
74 uint8_t signature[4]; /* "$OEM" */
77 uint16_t major:8; /* bits [7:0] */
78 uint16_t minor:8; /* bits [8:15] */
89 isci_get_oem_parameters(struct isci_softc *isci)
91 uint32_t OROM_PHYSICAL_ADDRESS_START = 0xC0000;
92 uint32_t OROM_SEARCH_LENGTH = 0x30000;
93 uint16_t OROM_SIGNATURE = 0xAA55;
94 uint32_t OROM_SIZE = 512;
96 (uint8_t *)BIOS_PADDRTOVADDR(OROM_PHYSICAL_ADDRESS_START);
99 while (offset < OROM_SEARCH_LENGTH) {
101 /* Look for the OROM signature at the beginning of every
102 * 512-byte block in the OROM region
104 if (*(uint16_t*)(orom_start + offset) == OROM_SIGNATURE) {
106 struct rom_header *rom_header;
107 struct pcir_header *pcir_header;
108 uint16_t vendor_id = isci->pci_common_header.vendor_id;
109 uint16_t device_id = isci->pci_common_header.device_id;
111 rom = (uint32_t *)(orom_start + offset);
112 rom_header = (struct rom_header *)rom;
113 pcir_header = (struct pcir_header *)
114 ((uint8_t*)rom + rom_header->pcir_pointer);
116 /* OROM signature was found. Now check if the PCI
117 * device and vendor IDs match.
119 if (pcir_header->vendor_id == vendor_id &&
120 pcir_header->device_id == device_id)
122 /* OROM for this PCI device was found. Search
123 * this 512-byte block for the $OEM string,
124 * which will mark the beginning of the OEM
127 uint8_t oem_sig[4] = {'$', 'O', 'E', 'M'};
130 for (dword_index = 0;
131 dword_index < OROM_SIZE/sizeof(uint32_t);
133 if (rom[dword_index] == *(uint32_t *)oem_sig) {
134 /* $OEM signature string was found. Now copy the OEM parameter block
135 * into the struct ISCI_CONTROLLER objects. After the controllers are
136 * constructed, we will pass this OEM parameter data to the SCI core
139 struct oem_parameters_table *oem =
140 (struct oem_parameters_table *)&rom[dword_index];
141 SCI_BIOS_OEM_PARAM_BLOCK_T *oem_data =
142 (SCI_BIOS_OEM_PARAM_BLOCK_T *)oem->data;
145 isci->oem_parameters_found = TRUE;
146 isci_log_message(1, "ISCI", "oem_data->header.num_elements = %d\n",
147 oem_data->header.num_elements);
149 for (index = 0; index < oem_data->header.num_elements; index++)
151 memcpy(&isci->controllers[index].oem_parameters.sds1,
152 &oem_data->controller_element[index],
153 sizeof(SCIC_SDS_OEM_PARAMETERS_T));
155 isci_log_message(1, "ISCI", "OEM Parameter Data for controller %d\n",
158 for (int i = 0; i < sizeof(SCIC_SDS_OEM_PARAMETERS_T); i++) {
159 uint8_t val = ((uint8_t *)&oem_data->controller_element[index])[i];
160 isci_log_message(1, "ISCI", "%02x ", val);
162 isci_log_message(1, "ISCI", "\n");
163 isci->controllers[index].oem_parameters_version = oem_data->header.version;
167 /* No need to continue searching for another
168 * OROM that matches this PCI device, so return