Support booting non FDT-capable loaders:
1. Allow embedding the FDT into the kernel, just like PowerPC/book-E. 2. If the loader passes us a pointer to the bootinfo structure, save it and use it to fill in the gaps (e.g. bus frequencies, etc).
This commit is contained in:
parent
5691ac3c34
commit
931f52388d
@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kstack_pages.h"
|
||||
#include "opt_msgbuf.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
@ -163,13 +164,18 @@ extern void dcache_inval(void);
|
||||
extern void icache_enable(void);
|
||||
extern void icache_inval(void);
|
||||
|
||||
/*
|
||||
* Bootinfo is passed to us by legacy loaders. Save the address of the
|
||||
* structure to handle backward compatibility.
|
||||
*/
|
||||
uint32_t *bootinfo;
|
||||
|
||||
struct kva_md_info kmi;
|
||||
struct pcpu __pcpu[MAXCPU];
|
||||
struct trapframe frame0;
|
||||
int cold = 1;
|
||||
long realmem = 0;
|
||||
long Maxmem = 0;
|
||||
|
||||
char machine[] = "powerpc";
|
||||
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
|
||||
|
||||
@ -294,6 +300,10 @@ e500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp)
|
||||
kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
|
||||
dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
|
||||
end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
|
||||
|
||||
bootinfo = (uint32_t *)preload_search_info(kmdp,
|
||||
MODINFO_METADATA | MODINFOMD_BOOTINFO);
|
||||
|
||||
#ifdef DDB
|
||||
ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
|
||||
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
|
||||
@ -313,6 +323,15 @@ e500_init(u_int32_t startkernel, u_int32_t endkernel, void *mdp)
|
||||
while (1);
|
||||
}
|
||||
|
||||
#if defined(FDT_DTB_STATIC)
|
||||
/*
|
||||
* In case the device tree blob was not retrieved (from metadata) try
|
||||
* to use the statically embedded one.
|
||||
*/
|
||||
if (dtbp == (vm_offset_t)NULL)
|
||||
dtbp = (vm_offset_t)&fdt_static_dtb;
|
||||
#endif
|
||||
|
||||
if (OF_install(OFW_FDT, 0) == FALSE)
|
||||
while (1);
|
||||
|
||||
|
@ -59,6 +59,8 @@ extern uint8_t __boot_page[]; /* Boot page body */
|
||||
extern uint32_t kernload; /* Kernel physical load address */
|
||||
#endif
|
||||
|
||||
extern uint32_t *bootinfo;
|
||||
|
||||
static int cpu, maxcpu;
|
||||
|
||||
static int bare_probe(platform_t);
|
||||
@ -160,24 +162,31 @@ bare_mem_regions(platform_t plat, struct mem_region **phys, int *physsz,
|
||||
static u_long
|
||||
bare_timebase_freq(platform_t plat, struct cpuref *cpuref)
|
||||
{
|
||||
u_long ticks = -1;
|
||||
u_long ticks;
|
||||
phandle_t cpus, child;
|
||||
pcell_t freq;
|
||||
|
||||
/* Backward compatibility. See 8-STABLE. */
|
||||
ticks = bootinfo[3] >> 3;
|
||||
|
||||
if ((cpus = OF_finddevice("/cpus")) == 0)
|
||||
goto out;
|
||||
|
||||
if ((child = OF_child(cpus)) == 0)
|
||||
goto out;
|
||||
|
||||
freq = 0;
|
||||
if (OF_getprop(child, "bus-frequency", (void *)&freq,
|
||||
sizeof(freq)) <= 0)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Time Base and Decrementer are updated every 8 CCB bus clocks.
|
||||
* HID0[SEL_TBCLK] = 0
|
||||
*/
|
||||
ticks = freq / 8;
|
||||
if (freq != 0)
|
||||
ticks = freq / 8;
|
||||
|
||||
out:
|
||||
if (ticks <= 0)
|
||||
panic("Unable to determine timebase frequency!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user