uint32_t tag;
const uint8_t *string;
} strings[] = {
- { LB_TAG_VERSION, linuxbios_version, },
- { LB_TAG_EXTRA_VERSION, linuxbios_extra_version, },
- { LB_TAG_BUILD, linuxbios_build, },
- { LB_TAG_COMPILE_TIME, linuxbios_compile_time, },
- { LB_TAG_COMPILE_BY, linuxbios_compile_by, },
- { LB_TAG_COMPILE_HOST, linuxbios_compile_host, },
- { LB_TAG_COMPILE_DOMAIN, linuxbios_compile_domain, },
- { LB_TAG_COMPILER, linuxbios_compiler, },
- { LB_TAG_LINKER, linuxbios_linker, },
- { LB_TAG_ASSEMBLER, linuxbios_assembler, },
+ { LB_TAG_VERSION, coreboot_version, },
+ { LB_TAG_EXTRA_VERSION, coreboot_extra_version, },
+ { LB_TAG_BUILD, coreboot_build, },
+ { LB_TAG_COMPILE_TIME, coreboot_compile_time, },
+ { LB_TAG_COMPILE_BY, coreboot_compile_by, },
+ { LB_TAG_COMPILE_HOST, coreboot_compile_host, },
+ { LB_TAG_COMPILE_DOMAIN, coreboot_compile_domain, },
+ { LB_TAG_COMPILER, coreboot_compiler, },
+ { LB_TAG_LINKER, coreboot_linker, },
+ { LB_TAG_ASSEMBLER, coreboot_assembler, },
};
unsigned int i;
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
{
int entries;
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
- mem->map[entries].start = start;
- mem->map[entries].size = size;
+ mem->map[entries].start = pack_lb64(start);
+ mem->map[entries].size = pack_lb64(size);
mem->map[entries].type = type;
mem->size += sizeof(mem->map[0]);
}
* setup so that is all we need to do.
*/
for(i = 0; i < entries; i++ ) {
- uint64_t map_start = mem->map[i].start;
- uint64_t map_end = map_start + mem->map[i].size;
+ uint64_t map_start = unpack_lb64(mem->map[i].start);
+ uint64_t map_end = map_start + unpack_lb64(mem->map[i].size);
/* Does this area need to be expanded? */
if (map_end == start) {
- mem->map[i].size = end - map_start;
+ mem->map[i].size = pack_lb64(end - map_start);
}
/* Does this area need to be contracted? */
else if (map_start == start) {
- mem->map[i].start = end;
- mem->map[i].size = map_end - end;
+ mem->map[i].start = pack_lb64(end);
+ mem->map[i].size = pack_lb64(map_end - end);
}
}
}
head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
head->header_checksum = 0;
head->header_checksum = compute_ip_checksum(head, sizeof(*head));
- printk_debug("Wrote linuxbios table at: %p - %p checksum %lx\n",
+ printk_debug("Wrote coreboot table at: %p - %p checksum %lx\n",
head, rec, head->table_checksum);
return (unsigned long)rec;
}
/* Sort the lb memory ranges */
for(i = 0; i < entries; i++) {
+ uint64_t entry_start = unpack_lb64(mem->map[i].start);
for(j = i; j < entries; j++) {
- if (mem->map[j].start < mem->map[i].start) {
+ uint64_t temp_start = unpack_lb64(mem->map[j].start);
+ if (temp_start < entry_start) {
struct lb_memory_range tmp;
tmp = mem->map[i];
mem->map[i] = mem->map[j];
if (mem->map[i].type != mem->map[i + 1].type) {
continue;
}
- start = mem->map[i].start;
- end = start + mem->map[i].size;
- nstart = mem->map[i + 1].start;
- nend = nstart + mem->map[i + 1].size;
+ start = unpack_lb64(mem->map[i].start);
+ end = start + unpack_lb64(mem->map[i].size);
+ nstart = unpack_lb64(mem->map[i + 1].start);
+ nend = nstart + unpack_lb64(mem->map[i + 1].size);
if ((start <= nstart) && (end > nstart)) {
if (start > nstart) {
start = nstart;
end = nend;
}
/* Record the new region size */
- mem->map[i].start = start;
- mem->map[i].size = end - start;
+ mem->map[i].start = pack_lb64(start);
+ mem->map[i].size = pack_lb64(end - start);
/* Delete the entry I have merged with */
memmove(&mem->map[i + 1], &mem->map[i + 2],
/* Remove a reserved area from the memory map */
for(i = 0; i < entries; i++) {
- uint64_t map_start = mem->map[i].start;
- uint64_t map_end = map_start + mem->map[i].size;
+ uint64_t map_start = unpack_lb64(mem->map[i].start);
+ uint64_t map_end = map_start + unpack_lb64(mem->map[i].size);
if ((start <= map_start) && (end >= map_end)) {
/* Remove the completely covered range */
memmove(&mem->map[i], &mem->map[i + 1],
mem->size += sizeof(mem->map[0]);
entries += 1;
/* Update the first map entry */
- mem->map[i].size = start - map_start;
+ mem->map[i].size = pack_lb64(start - map_start);
/* Update the second map entry */
- mem->map[i + 1].start = end;
- mem->map[i + 1].size = map_end - end;
+ mem->map[i + 1].start = pack_lb64(end);
+ mem->map[i + 1].size = pack_lb64(map_end - end);
/* Don't bother with this map entry again */
i += 1;
}
else if ((start <= map_start) && (end > map_start)) {
/* Shrink the start of the memory range */
- mem->map[i].start = end;
- mem->map[i].size = map_end - end;
+ mem->map[i].start = pack_lb64(end);
+ mem->map[i].size = pack_lb64(map_end - end);
}
else if ((start < map_end) && (start > map_start)) {
/* Shrink the end of the memory range */
- mem->map[i].size = start - map_start;
+ mem->map[i].size = pack_lb64(start - map_start);
}
}
}
lb_cleanup_memory_ranges(mem);
}
-/* Routines to extract part so the linuxBIOS table or
- * information from the linuxBIOS table after we have written it.
+/* Routines to extract part so the coreboot table or
+ * information from the coreboot table after we have written it.
* Currently get_lb_mem relies on a global we can change the
* implementaiton.
*/
return mem_ranges;
}
+static void build_lb_mem_range(void *gp, struct device *dev, struct resource *res)
+{
+ struct lb_memory *mem = gp;
+ lb_memory_range(mem, LB_MEM_RAM, res->base, res->size);
+}
+
static struct lb_memory *build_lb_mem(struct lb_header *head)
{
struct lb_memory *mem;
- struct device *dev;
/* Record where the lb memory ranges will live */
mem = lb_memory(head);
mem_ranges = mem;
/* Build the raw table of memory */
- for(dev = all_devices; dev; dev = dev->next) {
- struct resource *res, *last;
- last = &dev->resource[dev->resources];
- for(res = &dev->resource[0]; res < last; res++) {
- if (!(res->flags & IORESOURCE_MEM) ||
- !(res->flags & IORESOURCE_CACHEABLE)) {
- continue;
- }
- lb_memory_range(mem, LB_MEM_RAM, res->base, res->size);
- }
- }
+ search_global_resources(
+ IORESOURCE_MEM | IORESOURCE_CACHEABLE, IORESOURCE_MEM | IORESOURCE_CACHEABLE,
+ build_lb_mem_range, mem);
lb_cleanup_memory_ranges(mem);
return mem;
}
-unsigned long write_linuxbios_table(
+unsigned long write_coreboot_table(
unsigned long low_table_start, unsigned long low_table_end,
- unsigned long rom_table_startk, unsigned long rom_table_endk)
+ unsigned long rom_table_start, unsigned long rom_table_end)
{
unsigned long table_size;
struct lb_header *head;
struct lb_record *rec_dest, *rec_src;
/* Write the option config table... */
rec_dest = lb_new_record(head);
- rec_src = (struct lb_record *)&option_table;
+ rec_src = (struct lb_record *)(void *)&option_table;
memcpy(rec_dest, rec_src, rec_src->size);
}
/* Record where RAM is located */
/* Record the pirq table */
lb_add_memory_range(mem, LB_MEM_TABLE,
- rom_table_startk << 10, (rom_table_endk - rom_table_startk) << 10);
+ rom_table_start, (rom_table_end - rom_table_start));
/* Note:
* I assume that there is always memory at immediately after
- * the low_table_end. This means that after I setup the linuxbios table.
+ * the low_table_end. This means that after I setup the coreboot table.
* I can trivially fixup the reserved memory ranges to hold the correct
- * size of the linuxbios table.
+ * size of the coreboot table.
*/
/* Record our motheboard */