mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 15:22:43 +00:00
OpenFirmware/PowerPC loader, part 2.
As of this patchset, the loader builds (under NetBSD/macppc), boots, interacts and talks to BOOTP/NFS servers. (main.c was moved from boot/ofw/libofw to boot/ofw/common but has no revision history) Reviewed by: obrien
This commit is contained in:
parent
f1fb6c2132
commit
4cc1860f9b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=68548
@ -4,6 +4,10 @@ SRCS+= bcache.c boot.c commands.c console.c devopen.c interp.c
|
||||
SRCS+= interp_backslash.c interp_parse.c load_aout.c load_elf.c ls.c misc.c
|
||||
SRCS+= module.c panic.c
|
||||
|
||||
.if defined(LOADER_NET_SUPPORT)
|
||||
SRCS+= dev_net.c
|
||||
.endif
|
||||
|
||||
# Machine-independant ISA PnP
|
||||
.if HAVE_ISABUS
|
||||
SRCS+= isapnp.c
|
||||
|
3
sys/boot/ofw/common/Makefile.inc
Normal file
3
sys/boot/ofw/common/Makefile.inc
Normal file
@ -0,0 +1,3 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= main.c
|
@ -32,6 +32,7 @@
|
||||
#include "libofw.h"
|
||||
#include "bootstrap.h"
|
||||
|
||||
struct ofw_devdesc currdev; /* our current device */
|
||||
struct arch_switch archsw; /* MI/MD interface boundary */
|
||||
|
||||
extern char end[];
|
||||
@ -49,54 +50,54 @@ struct ofw_reg
|
||||
void
|
||||
init_heap(void)
|
||||
{
|
||||
phandle_t chosen, memory;
|
||||
ihandle_t meminstance;
|
||||
struct ofw_reg available;
|
||||
void * aligned_end;
|
||||
phandle_t chosen, memory;
|
||||
struct ofw_reg available;
|
||||
void * aligned_end;
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
|
||||
memory = OF_instance_to_package(meminstance);
|
||||
OF_getprop(memory, "available", &available, sizeof(available));
|
||||
printf("available.base = 0x%08x\n", available.base);
|
||||
printf("available.size = 0x%08x\n", available.size);
|
||||
printf("available.base = 0x%08x\n", available.base);
|
||||
printf("available.size = 0x%08x\n", available.size);
|
||||
|
||||
if (OF_claim((void *)available.base, 0x00040000, 0) ==
|
||||
if (OF_claim((void *)available.base, 0x00040000, 0) ==
|
||||
(void *) 0xffffffff) {
|
||||
printf("Heap memory claim failed!\n");
|
||||
OF_enter();
|
||||
}
|
||||
printf("Heap memory claim failed!\n");
|
||||
OF_enter();
|
||||
}
|
||||
|
||||
aligned_end = (void *)(((int)end + sizeof(int) - 1) &
|
||||
aligned_end = (void *)(((int)end + sizeof(int) - 1) &
|
||||
~(sizeof(int) - 1));
|
||||
printf("end = 0x%08x, aligned_end = 0x%08x\n", (uint32_t)end,
|
||||
printf("end = 0x%08x, aligned_end = 0x%08x\n", (uint32_t)end,
|
||||
(uint32_t)aligned_end);
|
||||
setheap((void *)aligned_end, (void *)(available.base + available.size));
|
||||
setheap((void *)aligned_end, (void *)(available.base + available.size));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
memsize(void)
|
||||
{
|
||||
phandle_t chosen, memory;
|
||||
ihandle_t meminstance;
|
||||
struct ofw_reg reg;
|
||||
phandle_t chosen, memory;
|
||||
struct ofw_reg reg;
|
||||
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
|
||||
memory = OF_instance_to_package(meminstance);
|
||||
|
||||
OF_getprop(memory, "reg", ®, sizeof(reg));
|
||||
OF_getprop(memory, "reg", ®, sizeof(reg));
|
||||
|
||||
return(reg.size);
|
||||
return (reg.size);
|
||||
}
|
||||
|
||||
int
|
||||
main(int (*openfirm)(void *))
|
||||
{
|
||||
#if 0
|
||||
void * test;
|
||||
#endif
|
||||
int i;
|
||||
int i;
|
||||
phandle_t chosen;
|
||||
char bootpath[64];
|
||||
char *ch;
|
||||
|
||||
/*
|
||||
* Initalise the OpenFirmware routines by giving them the entry point.
|
||||
@ -108,35 +109,82 @@ main(int (*openfirm)(void *))
|
||||
*/
|
||||
cons_probe();
|
||||
|
||||
printf(">>> hello?\n");
|
||||
/*
|
||||
* Initialise the heap as early as possible. Once this is done,
|
||||
* alloc() is usable. The stack is buried inside us, so this is
|
||||
* safe.
|
||||
*/
|
||||
init_heap();
|
||||
|
||||
/*
|
||||
* Initialise the heap as early as possible. Once this is done,
|
||||
* alloc() is usable. The stack is buried inside us, so this is
|
||||
* safe.
|
||||
*/
|
||||
init_heap();
|
||||
* Initialise the block cache
|
||||
*/
|
||||
bcache_init(32, 512); /* 16k XXX tune this */
|
||||
|
||||
/*
|
||||
* Initialise the block cache
|
||||
*/
|
||||
bcache_init(32, 512); /* 16k XXX tune this */
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for (i = 0; devsw[i] != NULL; i++)
|
||||
if (devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
|
||||
/*
|
||||
* March through the device switch probing for things.
|
||||
*/
|
||||
for(i = 0; devsw[i] != NULL; i++)
|
||||
if(devsw[i]->dv_init != NULL)
|
||||
(devsw[i]->dv_init)();
|
||||
printf("\n");
|
||||
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
|
||||
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
|
||||
printf("Memory: %dKB\n", memsize() / 1024);
|
||||
|
||||
printf("\n");
|
||||
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
|
||||
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
|
||||
printf("Memory: %dKB\n", memsize() / 1024);
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "bootpath", bootpath, 64);
|
||||
ch = index(bootpath, ':');
|
||||
*ch = '\0';
|
||||
printf("Booted from: %s\n", bootpath);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch (ofw_devicetype(bootpath)) {
|
||||
case DEVT_DISK:
|
||||
currdev.d_dev = &ofwdisk;
|
||||
currdev.d_type = DEVT_DISK;
|
||||
strncpy(currdev.d_kind.ofwdisk.path, bootpath, 64);
|
||||
currdev.d_kind.ofwdisk.unit = ofwd_getunit(bootpath);
|
||||
|
||||
if (currdev.d_kind.ofwdisk.unit == -1) {
|
||||
printf("Could not locate boot device.\n");
|
||||
OF_exit();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DEVT_NET:
|
||||
currdev.d_dev = &netdev;
|
||||
currdev.d_type = DEVT_NET;
|
||||
strncpy(currdev.d_kind.netif.path, bootpath, 64);
|
||||
/* XXX Only works when we only look for one net device */
|
||||
currdev.d_kind.netif.unit = 0;
|
||||
|
||||
break;
|
||||
|
||||
case DEVT_NONE:
|
||||
default:
|
||||
printf("\n");
|
||||
printf("Could not establish type of boot device.\n");
|
||||
OF_exit();
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
}
|
||||
|
||||
env_setenv("currdev", EV_VOLATILE, ofw_fmtdev(&currdev),
|
||||
ofw_setcurrdev, env_nounset);
|
||||
env_setenv("loaddev", EV_VOLATILE, ofw_fmtdev(&currdev), env_noset,
|
||||
env_nounset);
|
||||
setenv("LINES", "24", 1); /* optional */
|
||||
|
||||
archsw.arch_getdev = ofw_getdev;
|
||||
archsw.arch_copyin = ofw_copyin;
|
||||
archsw.arch_copyout = ofw_copyout;
|
||||
archsw.arch_readin = ofw_readin;
|
||||
|
||||
interact(); /* doesn't return */
|
||||
interact(); /* doesn't return */
|
||||
|
||||
OF_exit();
|
||||
|
||||
@ -148,6 +196,7 @@ COMMAND_SET(halt, "halt", "halt the system", command_halt);
|
||||
static int
|
||||
command_halt(int argc, char *argv[])
|
||||
{
|
||||
|
||||
OF_exit();
|
||||
return(CMD_OK);
|
||||
return (CMD_OK);
|
||||
}
|
@ -6,18 +6,28 @@ NOPROFILE= true
|
||||
INTERNALLIB= true
|
||||
INTERNALSTATICLIB= true
|
||||
|
||||
SRCS= devicename.c main.c ofw_copy.c ofw_module.c ofw_disk.c ofw_console.c \
|
||||
ofw_time.c ofw_devsearch.c ofw_reboot.c openfirm.c
|
||||
SRCS= devicename.c ofw_copy.c ofw_module.c ofw_disk.c ofw_net.c \
|
||||
ofw_console.c ofw_time.c ofw_devsearch.c ofw_reboot.c openfirm.c
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
|
||||
|
||||
# Pick up the bootstrap header for some interface items
|
||||
CFLAGS+= -I${.CURDIR}/../../common -msoft-float \
|
||||
-I${.CURDIR}/../../.. -I.
|
||||
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
|
||||
|
||||
.ifdef(BOOT_BIOSDISK_DEBUG)
|
||||
.if ${MACHINE_ARCH} == "powerpc"
|
||||
CFLAGS+= -msoft-float
|
||||
.endif
|
||||
|
||||
.ifdef(BOOT_DISK_DEBUG)
|
||||
# Make the disk code more talkative
|
||||
CFLAGS+= -DDISK_DEBUG
|
||||
.endif
|
||||
|
||||
machine:
|
||||
ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine
|
||||
|
||||
CLEANFILES+= machine
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
||||
beforedepend ${OBJS}: machine
|
||||
|
@ -184,3 +184,44 @@ ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path)
|
||||
free(idev);
|
||||
return(err);
|
||||
}
|
||||
|
||||
char *
|
||||
ofw_fmtdev(void *vdev)
|
||||
{
|
||||
struct ofw_devdesc *dev = (struct ofw_devdesc *)vdev;
|
||||
static char buf[128];
|
||||
char *cp;
|
||||
|
||||
switch(dev->d_type) {
|
||||
case DEVT_NONE:
|
||||
strcpy(buf, "(no device)");
|
||||
break;
|
||||
|
||||
case DEVT_DISK:
|
||||
/* XXX Insert stuff here */
|
||||
sprintf(buf, "%s%d:", dev->d_dev->dv_name,
|
||||
dev->d_kind.ofwdisk.unit);
|
||||
break;
|
||||
|
||||
case DEVT_NET:
|
||||
sprintf(buf, "%s%d:", dev->d_dev->dv_name,
|
||||
dev->d_kind.netif.unit);
|
||||
break;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
ofw_setcurrdev(struct env_var *ev, int flags, void *value)
|
||||
{
|
||||
struct ofw_devdesc *ncurr;
|
||||
int rv;
|
||||
|
||||
if ((rv = ofw_parsedev(&ncurr, value, NULL)) != 0)
|
||||
return rv;
|
||||
|
||||
free(ncurr);
|
||||
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,13 +32,14 @@ struct ofw_devdesc {
|
||||
union {
|
||||
struct {
|
||||
int unit;
|
||||
char path[64];
|
||||
int partition;
|
||||
int slice;
|
||||
int bsize;
|
||||
void *dmabuf;
|
||||
} ofwdisk;
|
||||
struct {
|
||||
int unit;
|
||||
char path[64];
|
||||
void *dmabuf;
|
||||
} netif;
|
||||
} d_kind;
|
||||
@ -64,13 +65,20 @@ extern int ofw_getdev(void **vdev, const char *devspec, const char **path);
|
||||
extern char *ofw_fmtdev(void *vdev);
|
||||
extern int ofw_setcurrdev(struct env_var *ev, int flags, void *value);
|
||||
|
||||
extern struct devsw ofwdisk;
|
||||
extern struct devsw ofwnet;
|
||||
extern struct devsw ofwdisk;
|
||||
extern struct netif_driver ofwnet;
|
||||
|
||||
int ofwd_getunit(const char *);
|
||||
int ofwn_getunit(const char *);
|
||||
|
||||
ssize_t ofw_copyin(const void *src, vm_offset_t dest, const size_t len);
|
||||
ssize_t ofw_copyout(const vm_offset_t src, void *dest, const size_t len);
|
||||
ssize_t ofw_readin(const int fd, vm_offset_t dest, const size_t len);
|
||||
|
||||
void ofw_devsearch_init(void);
|
||||
int ofw_devsearch(const char *, char *);
|
||||
int ofw_devicetype(char *);
|
||||
|
||||
extern int ofw_boot(void);
|
||||
extern int ofw_autoload(void);
|
||||
|
||||
|
@ -25,6 +25,9 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
|
||||
#include "libofw.h"
|
||||
#include "openfirm.h"
|
||||
|
||||
static phandle_t curnode;
|
||||
@ -107,3 +110,27 @@ ofw_devsearch(const char *type, char *path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the device_type of a node.
|
||||
* Return DEVT_DISK, DEVT_NET or DEVT_NONE.
|
||||
*/
|
||||
int
|
||||
ofw_devicetype(char *path)
|
||||
{
|
||||
phandle_t node;
|
||||
char type[16];
|
||||
|
||||
node = OF_finddevice(path);
|
||||
if (node == -1)
|
||||
return DEVT_NONE;
|
||||
|
||||
OF_getprop(node, "device_type", type, 16);
|
||||
|
||||
if (strncmp(type, "block", 16) == 0)
|
||||
return DEVT_DISK;
|
||||
else if (strncmp(type, "network", 16) == 0)
|
||||
return DEVT_NET;
|
||||
else
|
||||
return DEVT_NONE;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
f/*
|
||||
/*
|
||||
* Copyright (C) 2000 Benno Rice.
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -31,7 +31,6 @@ f/*
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/disklabel_mbr.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
@ -81,7 +80,7 @@ ofwd_init(void)
|
||||
if (instance != -1) {
|
||||
ofwdinfo[nofwdinfo].ofwd_unit = nofwdinfo;
|
||||
strncpy(ofwdinfo[nofwdinfo].ofwd_path, devpath, 255);
|
||||
printf("disk%d is %s\n", nofwdinfo, devpath);
|
||||
printf("disk%d is %s\n", nofwdinfo, ofwdinfo[nofwdinfo].ofwd_path);
|
||||
nofwdinfo++;
|
||||
OF_close(instance);
|
||||
}
|
||||
@ -117,6 +116,26 @@ ofwd_close(struct open_file *f)
|
||||
static void
|
||||
ofwd_print(int verbose)
|
||||
{
|
||||
printf("ofwd_print called.\n");
|
||||
int i;
|
||||
char line[80];
|
||||
|
||||
for (i = 0; i < nofwdinfo; i++) {
|
||||
sprintf(line, " disk%d: %s", i, ofwdinfo[i].ofwd_path);
|
||||
pager_output(line);
|
||||
pager_output("\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
ofwd_getunit(const char *path)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nofwdinfo; i++) {
|
||||
if (strcmp(path, ofwdinfo[i].ofwd_path) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -28,29 +28,35 @@
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <stand.h>
|
||||
#include <net.h>
|
||||
#include <netif.h>
|
||||
|
||||
int ofwn_probe();
|
||||
int ofwn_match();
|
||||
void ofwn_init();
|
||||
int ofwn_get();
|
||||
int ofwn_put();
|
||||
void ofwn_end();
|
||||
#include "openfirm.h"
|
||||
|
||||
extern struct netif_stats prom_stats[];
|
||||
static int ofwn_probe(struct netif *, void *);
|
||||
static int ofwn_match(struct netif *, void *);
|
||||
static void ofwn_init(struct iodesc *, void *);
|
||||
static int ofwn_get(struct iodesc *, void *, int, time_t);
|
||||
static int ofwn_put(struct iodesc *, void *, int);
|
||||
static void ofwn_end(struct netif *);
|
||||
|
||||
struct netif_dif prom_ifs[] = {
|
||||
extern struct netif_stats ofwn_stats[];
|
||||
|
||||
struct netif_dif ofwn_ifs[] = {
|
||||
/* dif_unit dif_nsel dif_stats dif_private */
|
||||
{ 0, 1, &prom_stats[0], 0, },
|
||||
{ 0, 1, &ofwn_stats[0], 0, },
|
||||
};
|
||||
|
||||
struct netif_stats prom_stats[NENTS(prom_ifs)];
|
||||
struct netif_stats ofwn_stats[NENTS(ofwn_ifs)];
|
||||
|
||||
struct netif_driver ofwnet = {
|
||||
"net", /* netif_bname */
|
||||
@ -64,132 +70,180 @@ struct netif_driver ofwnet = {
|
||||
NENTS(ofwn_ifs) /* netif_nifs */
|
||||
};
|
||||
|
||||
int netfd = 0, broken_firmware;
|
||||
static phandle_t netdevice;
|
||||
static ihandle_t netinstance;
|
||||
static ihandle_t memory;
|
||||
|
||||
int
|
||||
static void *dmabuf;
|
||||
|
||||
static int
|
||||
ofwn_match(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ofwn_probe(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ofwn_put(struct iodesc *desc, void *pkt, int len)
|
||||
{
|
||||
#if 0
|
||||
prom_write(netfd, len, pkt, 0);
|
||||
struct ether_header *eh;
|
||||
size_t sendlen;
|
||||
ssize_t rv;
|
||||
|
||||
return len;
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", desc, pkt, len);
|
||||
eh = pkt;
|
||||
printf("dst: %s ", ether_sprintf(eh->ether_dhost));
|
||||
printf("src: %s ", ether_sprintf(eh->ether_shost));
|
||||
printf("type: 0x%x\n", eh->ether_type & 0xffff);
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
sendlen = len;
|
||||
if (sendlen < 60) {
|
||||
sendlen = 60;
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("netif_put: length padded to %d\n", sendlen);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (dmabuf) {
|
||||
bcopy(pkt, dmabuf, sendlen);
|
||||
pkt = dmabuf;
|
||||
}
|
||||
|
||||
rv = OF_write(netinstance, pkt, len);
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("netif_put: OF_write returned %d\n", rv);
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ofwn_get(struct iodesc *desc, void *pkt, int len, time_t timeout)
|
||||
{
|
||||
return 0;
|
||||
time_t t;
|
||||
int length;
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("netif_get: pkt=%p, maxlen=%d, timeout=%d\n", pkt, len,
|
||||
timeout);
|
||||
#endif
|
||||
|
||||
t = getsecs();
|
||||
do {
|
||||
length = OF_read(netinstance, pkt, len);
|
||||
} while ((length == -2 || length == 0) &&
|
||||
(getsecs() - t < timeout));
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("netif_get: received length=%d (%x)\n", length, length);
|
||||
#endif
|
||||
|
||||
if (length < 12)
|
||||
return -1;
|
||||
|
||||
#if defined(NETIF_VERBOSE_DEBUG)
|
||||
{
|
||||
char *ch = pkt;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 96; i += 4) {
|
||||
printf("%02x%02x%02x%02x ", ch[i], ch[i+1],
|
||||
ch[i+2], ch[i+3]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
{
|
||||
struct ether_header *eh = pkt;
|
||||
|
||||
printf("dst: %s ", ether_sprintf(eh->ether_dhost));
|
||||
printf("src: %s ", ether_sprintf(eh->ether_shost));
|
||||
printf("type: 0x%x\n", eh->ether_type & 0xffff);
|
||||
}
|
||||
#endif
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
extern char *strchr();
|
||||
|
||||
void
|
||||
ofw_init(struct iodesc *desc, void *machdep_hint)
|
||||
static void
|
||||
ofwn_init(struct iodesc *desc, void *machdep_hint)
|
||||
{
|
||||
char devname[64];
|
||||
int devlen, i;
|
||||
int netbbinfovalid;
|
||||
char *enet_addr;
|
||||
prom_return_t ret;
|
||||
u_int64_t *qp, csum;
|
||||
phandle_t chosen, netdev;
|
||||
char path[64];
|
||||
char *ch;
|
||||
int pathlen;
|
||||
|
||||
broken_firmware = 0;
|
||||
chosen = OF_finddevice("/chosen");
|
||||
OF_getprop(chosen, "memory", &memory, sizeof(memory));
|
||||
pathlen = OF_getprop(chosen, "bootpath", path, 64);
|
||||
ch = index(path, ':');
|
||||
*ch = '\0';
|
||||
netdev = OF_finddevice(path);
|
||||
if (OF_getprop(netdev, "local-mac-address", desc->myea, 6) == -1)
|
||||
goto punt;
|
||||
|
||||
csum = 0;
|
||||
for (i = 0, qp = (u_int64_t *)&netbbinfo;
|
||||
i < (sizeof netbbinfo / sizeof (u_int64_t)); i++, qp++)
|
||||
csum += *qp;
|
||||
netbbinfovalid = (csum == 0);
|
||||
if (netbbinfovalid)
|
||||
netbbinfovalid = netbbinfo.set;
|
||||
|
||||
ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname));
|
||||
devlen = ret.u.retval;
|
||||
|
||||
/* Ethernet address is the 9th component of the booted_dev string. */
|
||||
enet_addr = devname;
|
||||
for (i = 0; i < 8; i++) {
|
||||
enet_addr = strchr(enet_addr, ' ');
|
||||
if (enet_addr == NULL) {
|
||||
printf(
|
||||
"boot: boot device name does not contain ethernet address.\n");
|
||||
goto punt;
|
||||
}
|
||||
enet_addr++;
|
||||
}
|
||||
if (enet_addr != NULL) {
|
||||
int hv, lv;
|
||||
|
||||
#define dval(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
|
||||
(((c) >= 'A' && (c) <= 'F') ? (10 + (c) - 'A') : \
|
||||
(((c) >= 'a' && (c) <= 'f') ? (10 + (c) - 'a') : -1)))
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
hv = dval(*enet_addr); enet_addr++;
|
||||
lv = dval(*enet_addr); enet_addr++;
|
||||
enet_addr++;
|
||||
|
||||
if (hv == -1 || lv == -1) {
|
||||
printf(
|
||||
"boot: boot device name contains bogus ethernet address.\n");
|
||||
goto punt;
|
||||
}
|
||||
|
||||
desc->myea[i] = (hv << 4) | lv;
|
||||
}
|
||||
#undef dval
|
||||
}
|
||||
|
||||
if (netbbinfovalid && netbbinfo.force) {
|
||||
printf("boot: using hard-coded ethernet address (forced).\n");
|
||||
bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea);
|
||||
}
|
||||
|
||||
gotit:
|
||||
printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea));
|
||||
|
||||
ret.bits = prom_open(devname, devlen + 1);
|
||||
if (ret.u.status) {
|
||||
printf("prom_init: open failed: %d\n", ret.u.status);
|
||||
goto reallypunt;
|
||||
}
|
||||
netfd = ret.u.retval;
|
||||
if ((netinstance = OF_open(path)) == -1)
|
||||
goto punt;
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("ofwn_init: OpenFirmware instance handle: %08x\n", netinstance);
|
||||
#endif
|
||||
|
||||
if (OF_call_method("dma-alloc", netinstance, 1, 1, MAXPHYS, &dmabuf)
|
||||
== -1)
|
||||
goto punt;
|
||||
|
||||
#if defined(NETIF_DEBUG)
|
||||
printf("ofwn_init: allocated DMA buffer: %08x\n", dmabuf);
|
||||
#endif
|
||||
|
||||
return;
|
||||
|
||||
punt:
|
||||
broken_firmware = 1;
|
||||
if (netbbinfovalid) {
|
||||
printf("boot: using hard-coded ethernet address.\n");
|
||||
bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea);
|
||||
goto gotit;
|
||||
}
|
||||
|
||||
reallypunt:
|
||||
printf("\n");
|
||||
printf("Boot device name was: \"%s\"\n", devname);
|
||||
printf("\n");
|
||||
printf("Your firmware may be too old to network-boot FreeBSD/alpha,\n");
|
||||
printf("or you might have to hard-code an ethernet address into\n");
|
||||
printf("your network boot block with setnetbootinfo(8).\n");
|
||||
halt();
|
||||
printf("Could not boot from %s.\n", path);
|
||||
OF_exit();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
ofwn_end(struct netif *nif)
|
||||
{
|
||||
prom_close(netfd);
|
||||
OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS);
|
||||
OF_close(netinstance);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
ofwn_getunit(const char *path)
|
||||
{
|
||||
int i;
|
||||
char newpath[255];
|
||||
|
||||
OF_canon(path, newpath, 254);
|
||||
|
||||
for (i = 0; i < nofwninfo; i++) {
|
||||
printf(">>> test =\t%s\n", ofwninfo[i].ofwn_path);
|
||||
if (strcmp(path, ofwninfo[i].ofwn_path) == 0)
|
||||
return i;
|
||||
|
||||
if (strcmp(newpath, ofwninfo[i].ofwn_path) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -39,3 +39,23 @@ time(time_t *tloc)
|
||||
*tloc = secs;
|
||||
return secs;
|
||||
}
|
||||
|
||||
int
|
||||
getsecs()
|
||||
{
|
||||
time_t n = 0;
|
||||
time(&n);
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
delay(int usecs)
|
||||
{
|
||||
int msecs, start;
|
||||
|
||||
msecs = usecs / 1000;
|
||||
start = OF_milliseconds();
|
||||
|
||||
while (OF_milliseconds() - start < msecs);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@
|
||||
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include <stand.h>
|
||||
|
||||
#include "openfirm.h"
|
||||
|
||||
static int (*openfirmware)(void *);
|
||||
@ -319,7 +321,7 @@ OF_setprop(phandle_t package, char *propname, void *buf, int len)
|
||||
|
||||
/* Convert a device specifier to a fully qualified pathname. */
|
||||
int
|
||||
OF_canon(char *device, char *buf, int len)
|
||||
OF_canon(const char *device, char *buf, int len)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -335,7 +337,7 @@ OF_canon(char *device, char *buf, int len)
|
||||
1,
|
||||
};
|
||||
|
||||
args.device = device;
|
||||
args.device = (char *)(uintptr_t *)device;
|
||||
args.buf = buf;
|
||||
args.len = len;
|
||||
if (openfirmware(&args) == -1)
|
||||
@ -345,7 +347,7 @@ OF_canon(char *device, char *buf, int len)
|
||||
|
||||
/* Return a package handle for the specified device. */
|
||||
phandle_t
|
||||
OF_finddevice(char *device)
|
||||
OF_finddevice(const char *device)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -359,7 +361,7 @@ OF_finddevice(char *device)
|
||||
1,
|
||||
};
|
||||
|
||||
args.device = device;
|
||||
args.device = (char *)(uintptr_t *)device;
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
return args.package;
|
||||
@ -523,8 +525,20 @@ OF_read(ihandle_t instance, void *addr, int len)
|
||||
args.instance = instance;
|
||||
args.addr = addr;
|
||||
args.len = len;
|
||||
|
||||
#if defined(OPENFIRM_DEBUG)
|
||||
printf("OF_read: called with instance=%08x, addr=%p, len=%d\n",
|
||||
args.instance, args.addr, args.len);
|
||||
#endif
|
||||
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
|
||||
#if defined(OPENFIRM_DEBUG)
|
||||
printf("OF_read: returning instance=%d, addr=%p, len=%d, actual=%d\n",
|
||||
args.instance, args.addr, args.len, args.actual);
|
||||
#endif
|
||||
|
||||
return args.actual;
|
||||
}
|
||||
|
||||
@ -556,7 +570,7 @@ OF_write(ihandle_t instance, void *addr, int len)
|
||||
|
||||
/* Seek to a position. */
|
||||
int
|
||||
OF_seek(ihandle_t instance, u_quad_t pos)
|
||||
OF_seek(ihandle_t instance, u_int64_t pos)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -674,7 +688,7 @@ OF_enter()
|
||||
}
|
||||
|
||||
/* Shut down and drop back to the OpenFirmware interface. */
|
||||
__dead void
|
||||
void
|
||||
OF_exit()
|
||||
{
|
||||
static struct {
|
||||
|
@ -85,8 +85,8 @@ int OF_getproplen(phandle_t, char *);
|
||||
int OF_getprop(phandle_t, char *, void *, int);
|
||||
int OF_nextprop(phandle_t, char *, char *);
|
||||
int OF_setprop(phandle_t, char *, void *, int);
|
||||
int OF_canon(char *, char *, int);
|
||||
phandle_t OF_finddevice(char *);
|
||||
int OF_canon(const char *, char *, int);
|
||||
phandle_t OF_finddevice(const char *);
|
||||
int OF_instance_to_path(ihandle_t, char *, int);
|
||||
int OF_package_to_path(phandle_t, char *, int);
|
||||
int OF_call_method(char *, ihandle_t, int, int, ...);
|
||||
@ -105,7 +105,7 @@ void OF_release(void *, u_int);
|
||||
/* Control transfer functions */
|
||||
void OF_boot(char *);
|
||||
void OF_enter(void);
|
||||
__dead void OF_exit(void) __attribute__((noreturn));
|
||||
void OF_exit(void) __attribute__((noreturn));
|
||||
void OF_chain(void *, u_int, void (*)(), void *, u_int);
|
||||
|
||||
#if 0
|
||||
|
@ -4,15 +4,26 @@ BASE= loader
|
||||
PROG= ${BASE}
|
||||
NOMAN=
|
||||
MAN1=
|
||||
STRIP=
|
||||
NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC
|
||||
BINDIR?= /boot
|
||||
|
||||
NOGCCERROR= YES
|
||||
LOADER_DISK_SUPPORT?= yes
|
||||
LOADER_NET_SUPPORT?= yes
|
||||
|
||||
# architecture-specific loader code
|
||||
SRCS= conf.c
|
||||
|
||||
# Pull in common loader code
|
||||
.PATH: ${.CURDIR}/../../ofw/common
|
||||
.include <${.CURDIR}/../../ofw/common/Makefile.inc>
|
||||
|
||||
.if defined(LOADER_DISK_SUPPORT)
|
||||
CFLAGS+= -DLOADER_DISK_SUPPORT
|
||||
.endif
|
||||
.if defined(LOADER_NET_SUPPORT)
|
||||
CFLAGS+= -DLOADER_NET_SUPPORT
|
||||
.endif
|
||||
|
||||
.if !defined(NOFORTH)
|
||||
# Enable BootForth
|
||||
@ -26,9 +37,10 @@ LIBFICL= ${.CURDIR}/../../ficl/libficl.a
|
||||
.endif
|
||||
|
||||
# Always add MI sources
|
||||
.PATH: ${.CURDIR}/../../common
|
||||
.include <${.CURDIR}/../../common/Makefile.inc>
|
||||
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
|
||||
.PATH: ${.CURDIR}/../../common
|
||||
.include <${.CURDIR}/../../common/Makefile.inc>
|
||||
CFLAGS+= -I${.CURDIR}/../../common
|
||||
CFLAGS+= -I${.CURDIR}/../../.. -I.
|
||||
|
||||
CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
|
||||
|
||||
@ -56,13 +68,16 @@ CFLAGS+= -elf
|
||||
# New linker set code
|
||||
#CFLAGS+= -DNEW_LINKER_SET
|
||||
|
||||
# Debug me!
|
||||
CFLAGS+= -g
|
||||
LDFLAGS+= -g
|
||||
|
||||
vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
|
||||
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
|
||||
${CC} -c vers.c
|
||||
|
||||
${BASE}.help: help.common help.ofw
|
||||
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
|
||||
> ${.TARGET}
|
||||
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
|
||||
|
||||
beforeinstall:
|
||||
.if exists(${DESTDIR}/boot/loader)
|
||||
@ -70,45 +85,40 @@ beforeinstall:
|
||||
.endif
|
||||
.if exists(${.OBJDIR}/loader.help)
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
.else
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
.endif
|
||||
.if !exists(${DESTDIR}/boot/loader.rc)
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
|
||||
.endif
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
|
||||
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
|
||||
|
||||
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \
|
||||
setdef1.o
|
||||
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \
|
||||
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
|
||||
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} start.o vers.o setdef0.o setdef1.o
|
||||
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o start.o ${OBJS} setdef1.o \
|
||||
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
|
||||
|
||||
setdef0.o: setdefs.h
|
||||
setdef0.o: setdefs.h
|
||||
|
||||
setdef1.o: setdefs.h
|
||||
setdef1.o: setdefs.h
|
||||
|
||||
machine:
|
||||
ln -sf ${.CURDIR}/../../../powerpc/include machine
|
||||
|
||||
# Cannot use ${OBJS} above this line
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
# If it's not there, don't consider it a target
|
||||
.if exists(${.CURDIR}/../../../ofw/include)
|
||||
beforedepend ${OBJS}: machine
|
||||
|
||||
machine:
|
||||
ln -sf ${.CURDIR}/../../../ofw/include machine
|
||||
|
||||
.endif
|
||||
|
||||
CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \
|
||||
powerpc.o
|
||||
start.o
|
||||
|
||||
.ORDER: setdefs.h setdef0.c setdef1.c
|
||||
setdefs.h setdef0.c setdef1.c: ${OBJS}
|
||||
|
@ -48,8 +48,7 @@ struct devsw *devsw[] = {
|
||||
&ofwdisk,
|
||||
#endif
|
||||
#if defined(LOADER_NET_SUPPORT)
|
||||
&ofwnet,
|
||||
&ofwnet,
|
||||
&netdev,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
@ -71,13 +70,11 @@ struct fs_ops *file_system[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
extern struct netif_driver of_net;
|
||||
|
||||
struct netif_driver *netif_drivers[] = {
|
||||
#ifdef LOADER_NET_SUPPORT
|
||||
&of_net,
|
||||
&ofwnet,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* Exported for PowerPC only */
|
||||
|
102
sys/boot/powerpc/loader/start.c
Normal file
102
sys/boot/powerpc/loader/start.c
Normal file
@ -0,0 +1,102 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
* Copyright (C) 1995, 1996 TooLs GmbH.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include "libofw.h"
|
||||
|
||||
void startup(void *, int, int (*)(void *), char *, int);
|
||||
|
||||
static int stack[8192/4 + 4];
|
||||
|
||||
#ifdef XCOFF_GLUE
|
||||
asm("
|
||||
.text
|
||||
.globl _entry
|
||||
_entry:
|
||||
.long _start,0,0
|
||||
");
|
||||
#endif
|
||||
|
||||
asm("
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
li 8,0
|
||||
li 9,0x100
|
||||
mtctr 9
|
||||
1:
|
||||
dcbf 0,8
|
||||
icbi 0,8
|
||||
addi 8,8,0x20
|
||||
bdnz 1b
|
||||
sync
|
||||
isync
|
||||
|
||||
lis 1,stack@ha
|
||||
addi 1,1,stack@l
|
||||
addi 1,1,8192
|
||||
|
||||
mfmsr 8
|
||||
li 0,0
|
||||
mtmsr 0
|
||||
isync
|
||||
|
||||
mtibatu 0,0
|
||||
mtibatu 1,0
|
||||
mtibatu 2,0
|
||||
mtibatu 3,0
|
||||
mtdbatu 0,0
|
||||
mtdbatu 1,0
|
||||
mtdbatu 2,0
|
||||
mtdbatu 3,0
|
||||
|
||||
li 9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */
|
||||
mtibatl 0,9
|
||||
mtdbatl 0,9
|
||||
li 9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */
|
||||
mtibatu 0,9
|
||||
mtdbatu 0,9
|
||||
isync
|
||||
|
||||
mtmsr 8
|
||||
isync
|
||||
|
||||
b startup
|
||||
");
|
||||
|
||||
void
|
||||
startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
|
||||
{
|
||||
main(openfirm);
|
||||
}
|
@ -4,15 +4,26 @@ BASE= loader
|
||||
PROG= ${BASE}
|
||||
NOMAN=
|
||||
MAN1=
|
||||
STRIP=
|
||||
NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC
|
||||
BINDIR?= /boot
|
||||
|
||||
NOGCCERROR= YES
|
||||
LOADER_DISK_SUPPORT?= yes
|
||||
LOADER_NET_SUPPORT?= yes
|
||||
|
||||
# architecture-specific loader code
|
||||
SRCS= conf.c
|
||||
|
||||
# Pull in common loader code
|
||||
.PATH: ${.CURDIR}/../../ofw/common
|
||||
.include <${.CURDIR}/../../ofw/common/Makefile.inc>
|
||||
|
||||
.if defined(LOADER_DISK_SUPPORT)
|
||||
CFLAGS+= -DLOADER_DISK_SUPPORT
|
||||
.endif
|
||||
.if defined(LOADER_NET_SUPPORT)
|
||||
CFLAGS+= -DLOADER_NET_SUPPORT
|
||||
.endif
|
||||
|
||||
.if !defined(NOFORTH)
|
||||
# Enable BootForth
|
||||
@ -26,9 +37,10 @@ LIBFICL= ${.CURDIR}/../../ficl/libficl.a
|
||||
.endif
|
||||
|
||||
# Always add MI sources
|
||||
.PATH: ${.CURDIR}/../../common
|
||||
.include <${.CURDIR}/../../common/Makefile.inc>
|
||||
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
|
||||
.PATH: ${.CURDIR}/../../common
|
||||
.include <${.CURDIR}/../../common/Makefile.inc>
|
||||
CFLAGS+= -I${.CURDIR}/../../common
|
||||
CFLAGS+= -I${.CURDIR}/../../.. -I.
|
||||
|
||||
CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
|
||||
|
||||
@ -56,13 +68,16 @@ CFLAGS+= -elf
|
||||
# New linker set code
|
||||
#CFLAGS+= -DNEW_LINKER_SET
|
||||
|
||||
# Debug me!
|
||||
CFLAGS+= -g
|
||||
LDFLAGS+= -g
|
||||
|
||||
vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
|
||||
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
|
||||
${CC} -c vers.c
|
||||
|
||||
${BASE}.help: help.common help.ofw
|
||||
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
|
||||
> ${.TARGET}
|
||||
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
|
||||
|
||||
beforeinstall:
|
||||
.if exists(${DESTDIR}/boot/loader)
|
||||
@ -70,45 +85,40 @@ beforeinstall:
|
||||
.endif
|
||||
.if exists(${.OBJDIR}/loader.help)
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
.else
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
|
||||
.endif
|
||||
.if !exists(${DESTDIR}/boot/loader.rc)
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
|
||||
.endif
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
|
||||
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
|
||||
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
|
||||
|
||||
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \
|
||||
setdef1.o
|
||||
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \
|
||||
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
|
||||
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} start.o vers.o setdef0.o setdef1.o
|
||||
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o start.o ${OBJS} setdef1.o \
|
||||
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
|
||||
|
||||
setdef0.o: setdefs.h
|
||||
setdef0.o: setdefs.h
|
||||
|
||||
setdef1.o: setdefs.h
|
||||
setdef1.o: setdefs.h
|
||||
|
||||
machine:
|
||||
ln -sf ${.CURDIR}/../../../powerpc/include machine
|
||||
|
||||
# Cannot use ${OBJS} above this line
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
# If it's not there, don't consider it a target
|
||||
.if exists(${.CURDIR}/../../../ofw/include)
|
||||
beforedepend ${OBJS}: machine
|
||||
|
||||
machine:
|
||||
ln -sf ${.CURDIR}/../../../ofw/include machine
|
||||
|
||||
.endif
|
||||
|
||||
CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \
|
||||
powerpc.o
|
||||
start.o
|
||||
|
||||
.ORDER: setdefs.h setdef0.c setdef1.c
|
||||
setdefs.h setdef0.c setdef1.c: ${OBJS}
|
||||
|
@ -48,8 +48,7 @@ struct devsw *devsw[] = {
|
||||
&ofwdisk,
|
||||
#endif
|
||||
#if defined(LOADER_NET_SUPPORT)
|
||||
&ofwnet,
|
||||
&ofwnet,
|
||||
&netdev,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
@ -71,13 +70,11 @@ struct fs_ops *file_system[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
extern struct netif_driver of_net;
|
||||
|
||||
struct netif_driver *netif_drivers[] = {
|
||||
#ifdef LOADER_NET_SUPPORT
|
||||
&of_net,
|
||||
&ofwnet,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* Exported for PowerPC only */
|
||||
|
102
sys/boot/powerpc/ofw/start.c
Normal file
102
sys/boot/powerpc/ofw/start.c
Normal file
@ -0,0 +1,102 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
* Copyright (C) 1995, 1996 TooLs GmbH.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include "libofw.h"
|
||||
|
||||
void startup(void *, int, int (*)(void *), char *, int);
|
||||
|
||||
static int stack[8192/4 + 4];
|
||||
|
||||
#ifdef XCOFF_GLUE
|
||||
asm("
|
||||
.text
|
||||
.globl _entry
|
||||
_entry:
|
||||
.long _start,0,0
|
||||
");
|
||||
#endif
|
||||
|
||||
asm("
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
li 8,0
|
||||
li 9,0x100
|
||||
mtctr 9
|
||||
1:
|
||||
dcbf 0,8
|
||||
icbi 0,8
|
||||
addi 8,8,0x20
|
||||
bdnz 1b
|
||||
sync
|
||||
isync
|
||||
|
||||
lis 1,stack@ha
|
||||
addi 1,1,stack@l
|
||||
addi 1,1,8192
|
||||
|
||||
mfmsr 8
|
||||
li 0,0
|
||||
mtmsr 0
|
||||
isync
|
||||
|
||||
mtibatu 0,0
|
||||
mtibatu 1,0
|
||||
mtibatu 2,0
|
||||
mtibatu 3,0
|
||||
mtdbatu 0,0
|
||||
mtdbatu 1,0
|
||||
mtdbatu 2,0
|
||||
mtdbatu 3,0
|
||||
|
||||
li 9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */
|
||||
mtibatl 0,9
|
||||
mtdbatl 0,9
|
||||
li 9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */
|
||||
mtibatu 0,9
|
||||
mtdbatu 0,9
|
||||
isync
|
||||
|
||||
mtmsr 8
|
||||
isync
|
||||
|
||||
b startup
|
||||
");
|
||||
|
||||
void
|
||||
startup(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl)
|
||||
{
|
||||
main(openfirm);
|
||||
}
|
@ -59,6 +59,8 @@
|
||||
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include <stand.h>
|
||||
|
||||
#include "openfirm.h"
|
||||
|
||||
static int (*openfirmware)(void *);
|
||||
@ -319,7 +321,7 @@ OF_setprop(phandle_t package, char *propname, void *buf, int len)
|
||||
|
||||
/* Convert a device specifier to a fully qualified pathname. */
|
||||
int
|
||||
OF_canon(char *device, char *buf, int len)
|
||||
OF_canon(const char *device, char *buf, int len)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -335,7 +337,7 @@ OF_canon(char *device, char *buf, int len)
|
||||
1,
|
||||
};
|
||||
|
||||
args.device = device;
|
||||
args.device = (char *)(uintptr_t *)device;
|
||||
args.buf = buf;
|
||||
args.len = len;
|
||||
if (openfirmware(&args) == -1)
|
||||
@ -345,7 +347,7 @@ OF_canon(char *device, char *buf, int len)
|
||||
|
||||
/* Return a package handle for the specified device. */
|
||||
phandle_t
|
||||
OF_finddevice(char *device)
|
||||
OF_finddevice(const char *device)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -359,7 +361,7 @@ OF_finddevice(char *device)
|
||||
1,
|
||||
};
|
||||
|
||||
args.device = device;
|
||||
args.device = (char *)(uintptr_t *)device;
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
return args.package;
|
||||
@ -523,8 +525,20 @@ OF_read(ihandle_t instance, void *addr, int len)
|
||||
args.instance = instance;
|
||||
args.addr = addr;
|
||||
args.len = len;
|
||||
|
||||
#if defined(OPENFIRM_DEBUG)
|
||||
printf("OF_read: called with instance=%08x, addr=%p, len=%d\n",
|
||||
args.instance, args.addr, args.len);
|
||||
#endif
|
||||
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
|
||||
#if defined(OPENFIRM_DEBUG)
|
||||
printf("OF_read: returning instance=%d, addr=%p, len=%d, actual=%d\n",
|
||||
args.instance, args.addr, args.len, args.actual);
|
||||
#endif
|
||||
|
||||
return args.actual;
|
||||
}
|
||||
|
||||
@ -556,7 +570,7 @@ OF_write(ihandle_t instance, void *addr, int len)
|
||||
|
||||
/* Seek to a position. */
|
||||
int
|
||||
OF_seek(ihandle_t instance, u_quad_t pos)
|
||||
OF_seek(ihandle_t instance, u_int64_t pos)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -674,7 +688,7 @@ OF_enter()
|
||||
}
|
||||
|
||||
/* Shut down and drop back to the OpenFirmware interface. */
|
||||
__dead void
|
||||
void
|
||||
OF_exit()
|
||||
{
|
||||
static struct {
|
||||
|
@ -85,8 +85,8 @@ int OF_getproplen(phandle_t, char *);
|
||||
int OF_getprop(phandle_t, char *, void *, int);
|
||||
int OF_nextprop(phandle_t, char *, char *);
|
||||
int OF_setprop(phandle_t, char *, void *, int);
|
||||
int OF_canon(char *, char *, int);
|
||||
phandle_t OF_finddevice(char *);
|
||||
int OF_canon(const char *, char *, int);
|
||||
phandle_t OF_finddevice(const char *);
|
||||
int OF_instance_to_path(ihandle_t, char *, int);
|
||||
int OF_package_to_path(phandle_t, char *, int);
|
||||
int OF_call_method(char *, ihandle_t, int, int, ...);
|
||||
@ -105,7 +105,7 @@ void OF_release(void *, u_int);
|
||||
/* Control transfer functions */
|
||||
void OF_boot(char *);
|
||||
void OF_enter(void);
|
||||
__dead void OF_exit(void) __attribute__((noreturn));
|
||||
void OF_exit(void) __attribute__((noreturn));
|
||||
void OF_chain(void *, u_int, void (*)(), void *, u_int);
|
||||
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user