1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#include "dec_prom.h"
#include "delo.h"
extern void *_edata;
extern void *_end;
void *malloc(int size);
const struct callback *callv;
int rex_prom = 0;
int main(int argc, char **argv, int magic, struct callback *cv ) {
int i,j,cargc;
int retval;
void (*entry)(int argc, char **argv, int magic, void *cv);
char *configbuffer,
**parray,
**cargv,
*kernel,
partition[3],
config[_MAX_CONFIG_NAME_LEN];
/* Clear BSS - This is a non-prom memset */
memset(_edata, 0x0, _end - _edata);
#if 0
callv=(void *) 0xa0004c70;
printf("cv %x\n",cv);
#endif
/* FIXME We only check for REX but dont handle it right now */
if (magic == DEC_REX_MAGIC) {
/* Store Call Vector */
callv=cv;
rex_prom=1;
}
puts("delo V0.7 Copyright 2000 Florian Lohoff <flo@rfc822.org>");
#if DEBUG
printf("callv addr %x\n",callv);
#endif
#ifdef DEBUG
for(i=0;i<argc;i++)
printf("clo: %d %s\n",
i,
argv[i]);
#endif
/*
* Boot command line will look like this:
*
* boot 3/rz0 5/vmlinux
*
* It might contain replacement argv stuff e.g
*
* boot 3/rz0 5/vmlinux root=/dev/sda5 console=ttyS2
*
* Now we dont use the config file args but the prom command line
*
*/
/* Initialize to empty partition name */
partition[0]=0x0;
/* Initialize to empty config name */
config[0]=0x0;
/* get partition name */
if (argc >= 3) {
for(i=0;i<strlen(argv[2]) && i < sizeof(partition);i++) {
if (argv[2][i] <= '9' && argv[2][i] >= '0')
partition[i]=argv[2][i];
else
break;
}
/* Set terminating 0x0 */
partition[i]=0x0;
/* Is there a slash ? */
if (argv[2][i] == '/') {
/* Copy config name */
strncpy(config, &argv[2][i+1], _MAX_CONFIG_NAME_LEN);
}
}
if (open_partition(partition)) {
return;
}
if (!(configbuffer=readfile(_CONFIG_FILE))) {
printf("Couldnt fetch config.file %s\n",_CONFIG_FILE);
return;
}
if (!(parray=getconfig(configbuffer, config))) {
printf("Couldnt find config %s\n", config);
return;
}
/* Do we have parms on the prom command line ? */
if (argc <= 3) {
/* FIXME This is completely stupid to work around
* a kernel stupidity - Probably the kernel should not
* skip anything and/or check for existance of "boot"
* at the beginning and skip only if this is the case */
if (rex_prom)
/*
* Copy pointer - We take 0 as the kernel
* will skip 2 parms anyway for REX so it doesnt
* care about our store usage
*/
cargv=&parray[0];
else
/*
* For non REX proms the kernel skips 1 arg
*/
cargv=&parray[1];
/* Count cargv values */
for(cargc=0;cargv[cargc];cargc++);
} else
cargc=0;
#ifdef DEBUG
for(i=0;i<cargc;i++)
printf("configargv: %d %s\n",
i,
cargv[i]);
#endif
if (!(kernel=readfile(parray[1]))) {
printf("Couldnt load kernel %s\n", parray[1]);
return;
}
if (!(entry=copyelf(kernel))) {
printf("Copying kernel failed\n");
return;
};
if (cargc != 0)
entry(cargc, cargv, magic, cv);
else
entry(argc, argv, magic, cv);
return;
}
|