Changeset View
Changeset View
Standalone View
Standalone View
stand/powerpc/ofw/main.c
| Show All 22 Lines | |||||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * 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 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
| * SUCH DAMAGE. | * SUCH DAMAGE. | ||||
| */ | */ | ||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
| __FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
| #include <sys/endian.h> | |||||
| #include <stand.h> | #include <stand.h> | ||||
| #include "openfirm.h" | #include "openfirm.h" | ||||
| #include "libofw.h" | #include "libofw.h" | ||||
| #include "bootstrap.h" | #include "bootstrap.h" | ||||
| #include <machine/asm.h> | |||||
| #include <machine/psl.h> | #include <machine/psl.h> | ||||
| struct arch_switch archsw; /* MI/MD interface boundary */ | struct arch_switch archsw; /* MI/MD interface boundary */ | ||||
| extern char end[]; | extern char end[]; | ||||
| uint32_t acells, scells; | uint32_t acells, scells; | ||||
| Show All 28 Lines | memsize(void) | ||||
| phandle_t memoryp; | phandle_t memoryp; | ||||
| cell_t reg[24]; | cell_t reg[24]; | ||||
| int i, sz; | int i, sz; | ||||
| uint64_t memsz; | uint64_t memsz; | ||||
| memsz = 0; | memsz = 0; | ||||
| memoryp = OF_instance_to_package(memory); | memoryp = OF_instance_to_package(memory); | ||||
| sz = OF_getprop(memoryp, "reg", ®, sizeof(reg)); | sz = OF_getencprop(memoryp, "reg", ®[0], sizeof(reg)); | ||||
| sz /= sizeof(reg[0]); | sz /= sizeof(reg[0]); | ||||
| for (i = 0; i < sz; i += (acells + scells)) { | for (i = 0; i < sz; i += (acells + scells)) { | ||||
| if (scells > 1) | if (scells > 1) | ||||
| memsz += (uint64_t)reg[i + acells] << 32; | memsz += (uint64_t)reg[i + acells] << 32; | ||||
| memsz += reg[i + acells + scells - 1]; | memsz += reg[i + acells + scells - 1]; | ||||
| } | } | ||||
| Show All 10 Lines | ppc64_autoload(void) | ||||
| if ((cas = getenv("cas")) && cas[0] == '1') | if ((cas = getenv("cas")) && cas[0] == '1') | ||||
| if (ppc64_cas() != 0) | if (ppc64_cas() != 0) | ||||
| return (-1); | return (-1); | ||||
| return (ofw_autoload()); | return (ofw_autoload()); | ||||
| } | } | ||||
| #endif | #endif | ||||
| #if BYTE_ORDER == LITTLE_ENDIAN | |||||
| /* | |||||
| * In Little-endian, we cannot just branch to the client interface. Since | |||||
| * the client interface is big endian, we have to rfid to it. | |||||
| * Likewise, when execution resumes, we are in the wrong endianness so | |||||
| * we must do a fixup before returning to the caller. | |||||
| */ | |||||
| static int (*openfirmware_entry)(void *); | |||||
| extern int openfirmware_trampoline(void *buf, int (*cb)(void *)); | |||||
| /* | |||||
| * Wrapper to pass the real entry point to our trampoline. | |||||
| */ | |||||
| static int | |||||
| openfirmware_docall(void *buf) | |||||
| { | |||||
| return openfirmware_trampoline(buf, openfirmware_entry); | |||||
| } | |||||
| #endif | |||||
| int | int | ||||
| main(int (*openfirm)(void *)) | main(int (*openfirm)(void *)) | ||||
| { | { | ||||
| phandle_t root; | phandle_t root; | ||||
| int i; | int i; | ||||
| char bootpath[64]; | char bootpath[64]; | ||||
| char *ch; | char *ch; | ||||
| int bargc; | int bargc; | ||||
| char **bargv; | char **bargv; | ||||
| /* | /* | ||||
| * Initialise the Open Firmware routines by giving them the entry point. | * Initialise the Open Firmware routines by giving them the entry point. | ||||
| */ | */ | ||||
| #if BYTE_ORDER == LITTLE_ENDIAN | |||||
| /* | |||||
| * Use a trampoline entry point for endian fixups. | |||||
| */ | |||||
| openfirmware_entry = openfirm; | |||||
| OF_init(openfirmware_docall); | |||||
| #else | |||||
| OF_init(openfirm); | OF_init(openfirm); | ||||
| #endif | |||||
| root = OF_finddevice("/"); | root = OF_finddevice("/"); | ||||
| scells = acells = 1; | scells = acells = 1; | ||||
| OF_getprop(root, "#address-cells", &acells, sizeof(acells)); | OF_getencprop(root, "#address-cells", &acells, sizeof(acells)); | ||||
| OF_getprop(root, "#size-cells", &scells, sizeof(scells)); | OF_getencprop(root, "#size-cells", &scells, sizeof(scells)); | ||||
| /* | /* | ||||
| * Initialise the heap as early as possible. Once this is done, | * Initialise the heap as early as possible. Once this is done, | ||||
| * alloc() is usable. The stack is buried inside us, so this is | * alloc() is usable. The stack is buried inside us, so this is | ||||
| * safe. | * safe. | ||||
| */ | */ | ||||
| init_heap(); | init_heap(); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||