mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Get rid of bootinfo for good in loader (U-Boot-based) and ARM.
For FDT-enabled platforms the device tree is a modern replacement for bootinfo config data.
This commit is contained in:
parent
d1d3233ebd
commit
6031d0b167
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=209909
@ -1,72 +0,0 @@
|
||||
/*-
|
||||
* Copyright (C) 2006-2008 Semihalf, Marian Balakowicz <m8@semihalf.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_BOOTINFO_H_
|
||||
#define _MACHINE_BOOTINFO_H_
|
||||
|
||||
#if !defined(LOCORE)
|
||||
|
||||
/* Platform hardware spec, received from loader(8) */
|
||||
|
||||
#define BI_VERSION 1
|
||||
|
||||
struct bi_mem_region {
|
||||
vm_paddr_t mem_base;
|
||||
vm_size_t mem_size;
|
||||
};
|
||||
|
||||
struct bi_eth_addr {
|
||||
u_int8_t mac_addr[6];
|
||||
u_int8_t padding[2];
|
||||
};
|
||||
|
||||
struct bootinfo {
|
||||
u_int32_t bi_version;
|
||||
vm_offset_t bi_bar_base;
|
||||
u_int32_t bi_cpu_clk;
|
||||
u_int32_t bi_bus_clk;
|
||||
u_int8_t bi_mem_reg_no;
|
||||
u_int8_t bi_eth_addr_no;
|
||||
u_int8_t padding[2];
|
||||
|
||||
u_int8_t bi_data[1];
|
||||
/*
|
||||
* The bi_data container is allocated in run time and has the
|
||||
* following layout:
|
||||
*
|
||||
* - bi_mem_reg_no elements of struct bi_mem_region
|
||||
* - bi_eth_addr_no elements of struct bi_eth_addr
|
||||
*/
|
||||
};
|
||||
|
||||
extern struct bootinfo *bootinfo;
|
||||
|
||||
struct bi_mem_region *bootinfo_mr(void);
|
||||
struct bi_eth_addr *bootinfo_eth(void);
|
||||
#endif
|
||||
|
||||
#endif /* _MACHINE_BOOTINFO_H_ */
|
@ -31,10 +31,4 @@
|
||||
|
||||
#define MODINFOMD_DTBP 0x1001
|
||||
|
||||
/*
|
||||
* XXX this is for tinderbox compilation sake only and will go away once the
|
||||
* FDT transition is complete.
|
||||
*/
|
||||
#define MODINFOMD_BOOTINFO 0x2000
|
||||
|
||||
#endif /* !_MACHINE_METADATA_H_ */
|
||||
|
@ -36,9 +36,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <machine/elf.h>
|
||||
#include <machine/metadata.h>
|
||||
#if !defined(LOADER_FDT_SUPPORT)
|
||||
#include <machine/bootinfo.h>
|
||||
#endif
|
||||
|
||||
#include "api_public.h"
|
||||
#include "bootstrap.h"
|
||||
@ -259,114 +256,6 @@ md_copymodules(vm_offset_t addr)
|
||||
return(addr);
|
||||
}
|
||||
|
||||
#if !defined(LOADER_FDT_SUPPORT)
|
||||
/*
|
||||
* Prepare the bootinfo structure. Put a ptr to the allocated struct in addr,
|
||||
* return size.
|
||||
*/
|
||||
static int
|
||||
md_bootinfo(struct bootinfo **addr)
|
||||
{
|
||||
#define TMP_MAX_ETH 8
|
||||
#define TMP_MAX_MR 8
|
||||
struct bootinfo *bi;
|
||||
struct bi_mem_region tmp_mr[TMP_MAX_MR];
|
||||
struct bi_eth_addr tmp_eth[TMP_MAX_ETH];
|
||||
struct sys_info *si;
|
||||
char *str, *end;
|
||||
const char *env;
|
||||
void *ptr;
|
||||
u_int8_t tmp_addr[6];
|
||||
int i, n, mr_no, eth_no, size;
|
||||
|
||||
if ((si = ub_get_sys_info()) == NULL)
|
||||
panic("can't retrieve U-Boot sysinfo");
|
||||
|
||||
/*
|
||||
* Handle mem regions (we only care about DRAM)
|
||||
*/
|
||||
for (i = 0, mr_no = 0; i < si->mr_no; i++) {
|
||||
if (si->mr[i].flags == MR_ATTR_DRAM) {
|
||||
if (mr_no >= TMP_MAX_MR) {
|
||||
printf("too many memory regions: %d\n", mr_no);
|
||||
break;
|
||||
}
|
||||
tmp_mr[mr_no].mem_base = si->mr[i].start;
|
||||
tmp_mr[mr_no].mem_size = si->mr[i].size;
|
||||
mr_no++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (mr_no == 0)
|
||||
panic("can't retrieve RAM info");
|
||||
|
||||
size = (mr_no * sizeof(struct bi_mem_region) - sizeof(bi->bi_data));
|
||||
|
||||
/*
|
||||
* Handle Ethernet addresses: parse u-boot env for eth%daddr
|
||||
*/
|
||||
env = NULL;
|
||||
eth_no = 0;
|
||||
while ((env = ub_env_enum(env)) != NULL) {
|
||||
if (strncmp(env, "eth", 3) == 0 &&
|
||||
strncmp(env + (strlen(env) - 4), "addr", 4) == 0) {
|
||||
|
||||
/* Extract interface number */
|
||||
i = strtol(env + 3, &end, 10);
|
||||
if (end == (env + 3))
|
||||
/* 'ethaddr' means interface 0 address */
|
||||
n = 0;
|
||||
else
|
||||
n = i;
|
||||
|
||||
if (n >= TMP_MAX_MR) {
|
||||
printf("Ethernet interface number too high: %d. "
|
||||
"Skipping...\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
str = ub_env_get(env);
|
||||
for (i = 0; i < 6; i++) {
|
||||
tmp_addr[i] = str ? strtol(str, &end, 16) : 0;
|
||||
if (str)
|
||||
str = (*end) ? end + 1 : end;
|
||||
|
||||
tmp_eth[n].mac_addr[i] = tmp_addr[i];
|
||||
}
|
||||
|
||||
/* eth_no is 1-based number of all interfaces defined */
|
||||
if (n + 1 > eth_no)
|
||||
eth_no = n + 1;
|
||||
}
|
||||
}
|
||||
|
||||
size += (eth_no * sizeof(struct bi_eth_addr)) + sizeof(struct bootinfo);
|
||||
|
||||
/*
|
||||
* Once its whole size is calculated, allocate space for the bootinfo
|
||||
* and copy over the contents from temp containers.
|
||||
*/
|
||||
if ((bi = malloc(size)) == NULL)
|
||||
panic("can't allocate mem for bootinfo");
|
||||
|
||||
ptr = (struct bi_mem_region *)bi->bi_data;
|
||||
bcopy(tmp_mr, ptr, mr_no * sizeof(struct bi_mem_region));
|
||||
ptr += mr_no * sizeof(struct bi_mem_region);
|
||||
bcopy(tmp_eth, ptr, eth_no * sizeof(struct bi_eth_addr));
|
||||
|
||||
bi->bi_mem_reg_no = mr_no;
|
||||
bi->bi_eth_addr_no = eth_no;
|
||||
bi->bi_version = BI_VERSION;
|
||||
bi->bi_bar_base = si->bar;
|
||||
bi->bi_cpu_clk = si->clk_cpu;
|
||||
bi->bi_bus_clk = si->clk_bus;
|
||||
|
||||
*addr = bi;
|
||||
|
||||
return (size);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load the information expected by a kernel.
|
||||
*
|
||||
@ -390,7 +279,6 @@ md_load(char *args, vm_offset_t *modulep)
|
||||
vm_offset_t dtbp;
|
||||
char *rootdevname;
|
||||
int howto;
|
||||
int bisize;
|
||||
int i;
|
||||
|
||||
/*
|
||||
@ -434,11 +322,6 @@ md_load(char *args, vm_offset_t *modulep)
|
||||
/* Pad to a page boundary */
|
||||
addr = roundup(addr, PAGE_SIZE);
|
||||
|
||||
#if !defined(LOADER_FDT_SUPPORT)
|
||||
/* prepare bootinfo */
|
||||
bisize = md_bootinfo(&bip);
|
||||
#endif
|
||||
|
||||
kernend = 0;
|
||||
kfp = file_findfile(NULL, "elf32 kernel");
|
||||
if (kfp == NULL)
|
||||
@ -457,8 +340,6 @@ md_load(char *args, vm_offset_t *modulep)
|
||||
|
||||
dtbp = bfp == NULL ? 0 : bfp->f_addr;
|
||||
file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp);
|
||||
#else
|
||||
file_addmetadata(kfp, MODINFOMD_BOOTINFO, bisize, bip);
|
||||
#endif
|
||||
|
||||
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
|
||||
|
Loading…
Reference in New Issue
Block a user