Where we can, pass the kernel an FDT facsimile of the OF device tree rather
than a pointer to Open Firmware by default. This eliminates a number of potentially unsafe calls to firmware from the kernel and provides better performance. This feature is meant to be expanded until it is on by default unconditionally and, ideally, we can then garbage-collect the nightmare pile of hacks required to call into Open Firmware from a live kernel. Reviewed by: jhibbits
This commit is contained in:
parent
2ed9eb5dae
commit
18a119d74c
@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include "libofw.h"
|
||||
#include "bootstrap.h"
|
||||
|
||||
#include <machine/psl.h>
|
||||
|
||||
struct arch_switch archsw; /* MI/MD interface boundary */
|
||||
|
||||
extern char end[];
|
||||
@ -47,6 +49,16 @@ static char heap[HEAP_SIZE]; // In BSS, so uses no space
|
||||
|
||||
#define OF_puts(fd, text) OF_write(fd, text, strlen(text))
|
||||
|
||||
static __inline register_t
|
||||
mfmsr(void)
|
||||
{
|
||||
register_t value;
|
||||
|
||||
__asm __volatile ("mfmsr %0" : "=r"(value));
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
void
|
||||
init_heap(void)
|
||||
{
|
||||
@ -145,6 +157,15 @@ main(int (*openfirm)(void *))
|
||||
env_nounset);
|
||||
setenv("LINES", "24", 1); /* optional */
|
||||
|
||||
/*
|
||||
* On non-Apple hardware, where it works reliably, pass flattened
|
||||
* device trees to the kernel by default instead of OF CI pointers.
|
||||
* Apple hardware is the only virtual-mode OF implementation in
|
||||
* existence, so far as I am aware, so use that as a flag.
|
||||
*/
|
||||
if (!(mfmsr() & PSL_DR))
|
||||
setenv("usefdt", "1", 1);
|
||||
|
||||
archsw.arch_getdev = ofw_getdev;
|
||||
archsw.arch_copyin = ofw_copyin;
|
||||
archsw.arch_copyout = ofw_copyout;
|
||||
|
Loading…
Reference in New Issue
Block a user