Lines Matching +full:partitions +full:- +full:table +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
12 * The EPROM is logically divided into three partitions:
24 #define EP_PAGE_MASK (EP_PAGE_SIZE - 1)
45 * All callers have verified the offset is at a page boundary.
47 static void read_page(struct hfi1_devdata *dd, u32 offset, u32 *result) in read_page() argument
51 write_csr(dd, ASIC_EEP_ADDR_CMD, CMD_READ_DATA(offset)); in read_page()
58 * Read length bytes starting at offset from the start of the EPROM.
75 * command address range. Note that '>' is correct below - the end in read_length()
79 return -EINVAL; in read_length()
91 bytes = EP_PAGE_SIZE - start_offset; in read_length()
102 len -= bytes; in read_length()
113 len -= EP_PAGE_SIZE; in read_length()
134 if (dd->pcidev->device != PCI_DEVICE_ID_INTEL0) in eprom_init()
160 dd->eprom_available = true; in eprom_init()
175 /* segment size - 128 KiB */
187 u32 offset; /* file offset from start of EPROM */ member
192 * Calculate the max number of table entries that will fit within a directory
196 (((dir_size) - sizeof(struct hfi1_eprom_footer)) / \
220 return -ENOMEM; in read_partition_platform_config()
231 return -ENOENT; in read_partition_platform_config()
237 length = p - buffer; in read_partition_platform_config()
247 * The segment magic has been checked. There is a footer and table of
256 struct hfi1_eprom_table_entry *table; in read_segment_platform_config() local
267 (directory + EP_PAGE_SIZE - sizeof(*footer)); in read_segment_platform_config()
270 if (footer->version != FOOTER_VERSION) in read_segment_platform_config()
271 return -EINVAL; in read_segment_platform_config()
274 if (footer->oprom_size >= SEG_SIZE) in read_segment_platform_config()
275 return -EINVAL; in read_segment_platform_config()
277 /* the file table must fit in a segment with the oprom */ in read_segment_platform_config()
278 if (footer->num_table_entries > in read_segment_platform_config()
279 MAX_TABLE_ENTRIES(SEG_SIZE - footer->oprom_size)) in read_segment_platform_config()
280 return -EINVAL; in read_segment_platform_config()
282 /* find the file table start, which precedes the footer */ in read_segment_platform_config()
283 directory_size = DIRECTORY_SIZE(footer->num_table_entries); in read_segment_platform_config()
285 /* the file table fits into the directory buffer handed in */ in read_segment_platform_config()
286 table = (struct hfi1_eprom_table_entry *) in read_segment_platform_config()
287 (directory + EP_PAGE_SIZE - directory_size); in read_segment_platform_config()
292 return -ENOMEM; in read_segment_platform_config()
293 ret = read_length(dd, SEG_SIZE - directory_size, in read_segment_platform_config()
297 table = table_buffer; in read_segment_platform_config()
300 /* look for the platform configuration file in the table */ in read_segment_platform_config()
301 for (entry = NULL, i = 0; i < footer->num_table_entries; i++) { in read_segment_platform_config()
302 if (table[i].type == HFI1_EFT_PLATFORM_CONFIG) { in read_segment_platform_config()
303 entry = &table[i]; in read_segment_platform_config()
308 ret = -ENOENT; in read_segment_platform_config()
313 * Sanity check on the configuration file size - it should never in read_segment_platform_config()
316 if (entry->size > (4 * 1024)) { in read_segment_platform_config()
318 entry->size); in read_segment_platform_config()
319 ret = -EINVAL; in read_segment_platform_config()
323 /* check for bogus offset and size that wrap when added together */ in read_segment_platform_config()
324 if (entry->offset + entry->size < entry->offset) { in read_segment_platform_config()
327 entry->offset, entry->size); in read_segment_platform_config()
328 ret = -EINVAL; in read_segment_platform_config()
333 buffer = kmalloc(entry->size, GFP_KERNEL); in read_segment_platform_config()
335 ret = -ENOMEM; in read_segment_platform_config()
342 seg_offset = entry->offset % SEG_SIZE; in read_segment_platform_config()
343 seg_base = entry->offset - seg_offset; in read_segment_platform_config()
345 while (ncopied < entry->size) { in read_segment_platform_config()
348 /* start with the bytes from the current offset to the end */ in read_segment_platform_config()
349 bytes_available = SEG_SIZE - seg_offset; in read_segment_platform_config()
350 /* subtract off footer and table from segment 0 */ in read_segment_platform_config()
358 "Bad configuration file - offset 0x%x within footer+table\n", in read_segment_platform_config()
359 entry->offset); in read_segment_platform_config()
360 ret = -EINVAL; in read_segment_platform_config()
363 bytes_available -= directory_size; in read_segment_platform_config()
367 to_copy = entry->size - ncopied; in read_segment_platform_config()
376 * The sanity check for entry->offset is done in read_length(). in read_segment_platform_config()
377 * The EPROM offset is validated against what the hardware in read_segment_platform_config()
378 * addressing supports. In addition, if the offset is larger in read_segment_platform_config()
391 seg_offset = footer->oprom_size; in read_segment_platform_config()
398 *size = entry->size; in read_segment_platform_config()
414 * 0 - success
415 * -ENXIO - no EPROM is available
416 * -EBUSY - not able to acquire access to the EPROM
417 * -ENOENT - no recognizable file written
418 * -ENOMEM - buffer could not be allocated
419 * -EINVAL - invalid EPROM contentents found
426 if (!dd->eprom_available) in eprom_read_platform_config()
427 return -ENXIO; in eprom_read_platform_config()
431 return -EBUSY; in eprom_read_platform_config()
434 ret = read_length(dd, SEG_SIZE - EP_PAGE_SIZE, EP_PAGE_SIZE, directory); in eprom_read_platform_config()
439 if (directory[EP_PAGE_DWORDS - 1] == FOOTER_MAGIC) { in eprom_read_platform_config()