imx8: load a plan9.ini at CONFADDR 0x40010000

This commit is contained in:
cinap_lenrek 2022-07-10 16:40:36 +00:00
parent cd64b7129c
commit 65bd53b9b8
3 changed files with 118 additions and 19 deletions

View file

@ -14,6 +14,114 @@
Conf conf; Conf conf;
#define MAXCONF 64
static char *confname[MAXCONF];
static char *confval[MAXCONF];
static int nconf;
void
bootargsinit(void)
{
int i, j, n;
char *cp, *line[MAXCONF], *p, *q;
/*
* parse configuration args from dos file plan9.ini
*/
cp = BOOTARGS; /* where b.com leaves its config */
cp[BOOTARGSLEN-1] = 0;
/*
* Strip out '\r', change '\t' -> ' '.
*/
p = cp;
for(q = cp; *q; q++){
if(*q == -1)
break;
if(*q == '\r')
continue;
if(*q == '\t')
*q = ' ';
*p++ = *q;
}
*p = 0;
n = getfields(cp, line, MAXCONF, 1, "\n");
for(i = 0; i < n; i++){
if(*line[i] == '#')
continue;
cp = strchr(line[i], '=');
if(cp == nil)
continue;
*cp++ = '\0';
for(j = 0; j < nconf; j++){
if(cistrcmp(confname[j], line[i]) == 0)
break;
}
confname[j] = line[i];
confval[j] = cp;
if(j == nconf)
nconf++;
}
}
char*
getconf(char *name)
{
int i;
for(i = 0; i < nconf; i++)
if(cistrcmp(confname[i], name) == 0)
return confval[i];
return nil;
}
void
setconfenv(void)
{
int i;
for(i = 0; i < nconf; i++){
if(confname[i][0] != '*')
ksetenv(confname[i], confval[i], 0);
ksetenv(confname[i], confval[i], 1);
}
}
void
writeconf(void)
{
char *p, *q;
int n;
p = getconfenv();
if(waserror()) {
free(p);
nexterror();
}
/* convert to name=value\n format */
for(q=p; *q; q++) {
q += strlen(q);
*q = '=';
q += strlen(q);
*q = '\n';
}
n = q - p + 1;
if(n >= BOOTARGSLEN)
error("kernel configuration too large");
memmove(BOOTARGS, p, n);
memset(BOOTARGS+n, 0, BOOTARGSLEN-n);
poperror();
free(p);
}
int
isaconfig(char *, int, ISAConf *)
{
return 0;
}
/* /*
* starting place for first process * starting place for first process
*/ */
@ -31,6 +139,7 @@ init0(void)
else else
ksetenv("service", "terminal", 0); ksetenv("service", "terminal", 0);
ksetenv("console", "0", 0); ksetenv("console", "0", 0);
setconfenv();
poperror(); poperror();
} }
kproc("alarm", alarmkproc, 0); kproc("alarm", alarmkproc, 0);
@ -161,6 +270,7 @@ main(void)
return; return;
} }
quotefmtinstall(); quotefmtinstall();
bootargsinit();
meminit(); meminit();
confinit(); confinit();
xinit(); xinit();
@ -200,23 +310,6 @@ exit(int)
smccall(&u); smccall(&u);
} }
int
isaconfig(char *, int, ISAConf *)
{
return 0;
}
char*
getconf(char *)
{
return nil;
}
void
writeconf(void)
{
}
static void static void
rebootjump(void *entry, void *code, ulong size) rebootjump(void *entry, void *code, ulong size)
{ {

View file

@ -64,6 +64,10 @@
#define MACHADDR(n) (KTZERO-((n)+1)*MACHSIZE) #define MACHADDR(n) (KTZERO-((n)+1)*MACHSIZE)
#define CONFADDR (VDRAM + 0x10000) /* 0x40010000 */ #define CONFADDR (VDRAM + 0x10000) /* 0x40010000 */
#define BOOTARGS ((char*)CONFADDR)
#define BOOTARGSLEN 0x10000
#define REBOOTADDR (VDRAM-KZERO + 0x20000) /* 0x40020000 */ #define REBOOTADDR (VDRAM-KZERO + 0x20000) /* 0x40020000 */
#define UZERO 0ULL /* user segment */ #define UZERO 0ULL /* user segment */

View file

@ -1,2 +1,4 @@
load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} ${prefix}9reform.u mw.b 0x40010000 0x0 0x10000
bootm ${kernel_addr_r} load ${devtype} ${devnum}:${bootpart} 0x40010000 ${prefix}plan9.ini
load ${devtype} ${devnum}:${bootpart} 0x40100000 ${prefix}9reform.u
bootm 0x40100000