9boot: make print handle \n -> \r\n conversion, style
This commit is contained in:
parent
ec15df1d81
commit
364f1f78d4
6 changed files with 59 additions and 71 deletions
|
@ -384,21 +384,21 @@ start(void *sp)
|
||||||
drive = ((ushort*)sp)[5] & 0xFF;
|
drive = ((ushort*)sp)[5] & 0xFF;
|
||||||
|
|
||||||
if(findfat(&fat, drive, 0, 0)){
|
if(findfat(&fat, drive, 0, 0)){
|
||||||
print("no fat\r\n");
|
print("no fat\n");
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
if(fatwalk(f = &fi, &fat, "plan9.ini")){
|
if(fatwalk(f = &fi, &fat, "plan9.ini")){
|
||||||
print("no config\r\n");
|
print("no config\n");
|
||||||
f = 0;
|
f = 0;
|
||||||
}
|
}
|
||||||
for(;;){
|
for(;;){
|
||||||
kern = configure(f, path); f = 0;
|
kern = configure(f, path); f = 0;
|
||||||
if(fatwalk(&fi, &fat, kern)){
|
if(fatwalk(&fi, &fat, kern)){
|
||||||
print("not found\r\n");
|
print("not found\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
print(bootkern(&fi));
|
print(bootkern(&fi));
|
||||||
print(crnl);
|
print("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* handy strings in l.s */
|
/* handy strings in l.s */
|
||||||
extern char origin[];
|
extern char origin[];
|
||||||
extern char hex[];
|
extern char hex[];
|
||||||
extern char crnl[];
|
|
||||||
extern char bootname[];
|
extern char bootname[];
|
||||||
|
|
||||||
/* l.s */
|
/* l.s */
|
||||||
|
|
|
@ -161,17 +161,17 @@ start(void *sp)
|
||||||
close(&ex);
|
close(&ex);
|
||||||
|
|
||||||
if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
|
if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
|
||||||
print("no config\r\n");
|
print("no config\n");
|
||||||
f = 0;
|
f = 0;
|
||||||
}
|
}
|
||||||
for(;;){
|
for(;;){
|
||||||
kern = configure(f, path); f = 0;
|
kern = configure(f, path); f = 0;
|
||||||
if(isowalk(&ex, drive, kern)){
|
if(isowalk(&ex, drive, kern)){
|
||||||
print("not found\r\n");
|
print("not found\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
print(bootkern(&ex));
|
print(bootkern(&ex));
|
||||||
print(crnl);
|
print("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,9 +295,6 @@ TEXT bootname(SB), $0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEXT crnl(SB), $0
|
|
||||||
BYTE $'\r'; BYTE $'\n'; BYTE $0
|
|
||||||
|
|
||||||
TEXT hex(SB), $0
|
TEXT hex(SB), $0
|
||||||
BYTE $'0'; BYTE $'1'; BYTE $'2'; BYTE $'3';
|
BYTE $'0'; BYTE $'1'; BYTE $'2'; BYTE $'3';
|
||||||
BYTE $'4'; BYTE $'5'; BYTE $'6'; BYTE $'7';
|
BYTE $'4'; BYTE $'5'; BYTE $'6'; BYTE $'7';
|
||||||
|
|
|
@ -268,7 +268,7 @@ read(void *f, void *data, int len)
|
||||||
break;
|
break;
|
||||||
case Tftp_ERROR:
|
case Tftp_ERROR:
|
||||||
print(t->pkt+4);
|
print(t->pkt+4);
|
||||||
print(crnl);
|
print("\n");
|
||||||
default:
|
default:
|
||||||
t->eof = 1;
|
t->eof = 1;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -336,27 +336,27 @@ start(void *)
|
||||||
Tftp t;
|
Tftp t;
|
||||||
|
|
||||||
if(pxeinit()){
|
if(pxeinit()){
|
||||||
print("pxe init\r\n");
|
print("pxe init\n");
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
if(getip(yip, sip, gip, mac)){
|
if(getip(yip, sip, gip, mac)){
|
||||||
print("bad dhcp\r\n");
|
print("bad dhcp\n");
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
memmove(path, "/cfg/pxe/", 9);
|
memmove(path, "/cfg/pxe/", 9);
|
||||||
memmove(path+9, mac, 13);
|
memmove(path+9, mac, 13);
|
||||||
if(tftpopen(f = &t, path, yip, sip, gip))
|
if(tftpopen(f = &t, path, yip, sip, gip))
|
||||||
if(tftpopen(f, "/cfg/pxe/default", yip, sip, gip)){
|
if(tftpopen(f, "/cfg/pxe/default", yip, sip, gip)){
|
||||||
print("no config\r\n");
|
print("no config\n");
|
||||||
f = 0;
|
f = 0;
|
||||||
}
|
}
|
||||||
for(;;){
|
for(;;){
|
||||||
kern = configure(f, path); f = 0;
|
kern = configure(f, path); f = 0;
|
||||||
if(tftpopen(&t, kern, yip, sip, gip)){
|
if(tftpopen(&t, kern, yip, sip, gip)){
|
||||||
print("not found\r\n");
|
print("not found\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
print(bootkern(&t));
|
print(bootkern(&t));
|
||||||
print(crnl);
|
print("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,11 @@ memcmp(void *src, void *dst, int n)
|
||||||
uchar *s = src;
|
uchar *s = src;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
while(n-- > 0)
|
while(n-- > 0){
|
||||||
if(r = (*d++ - *s++))
|
r = *d++ - *s++;
|
||||||
|
if(r != 0)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +52,7 @@ strlen(char *s)
|
||||||
{
|
{
|
||||||
char *p = s;
|
char *p = s;
|
||||||
|
|
||||||
while(*p)
|
while(*p != '\0')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
return p - s;
|
return p - s;
|
||||||
|
@ -59,18 +61,21 @@ strlen(char *s)
|
||||||
char*
|
char*
|
||||||
strchr(char *s, int c)
|
strchr(char *s, int c)
|
||||||
{
|
{
|
||||||
for(; *s; s++)
|
for(; *s != 0; s++)
|
||||||
if(*s == c)
|
if(*s == c)
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
return 0;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print(char *s)
|
print(char *s)
|
||||||
{
|
{
|
||||||
while(*s)
|
while(*s != 0){
|
||||||
|
if(*s == '\n')
|
||||||
|
putc('\r');
|
||||||
putc(*s++);
|
putc(*s++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -103,10 +108,10 @@ readline(void *f, char buf[64])
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
do{
|
do{
|
||||||
if(!f)
|
if(f == nil)
|
||||||
putc('>');
|
putc('>');
|
||||||
for(;;){
|
for(;;){
|
||||||
if(!f){
|
if(f == nil){
|
||||||
putc(*p = getc());
|
putc(*p = getc());
|
||||||
if(*p == '\r')
|
if(*p == '\r')
|
||||||
putc('\n');
|
putc('\n');
|
||||||
|
@ -116,12 +121,12 @@ readline(void *f, char buf[64])
|
||||||
}
|
}
|
||||||
}else if(read(f, p, 1) <= 0)
|
}else if(read(f, p, 1) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
if(strchr(crnl, *p))
|
if(strchr("\r\n", *p) != nil)
|
||||||
break;
|
break;
|
||||||
if(p == buf && strchr(white, *p))
|
if(p == buf && strchr(white, *p) != nil)
|
||||||
continue; /* whitespace on start of line */
|
continue; /* whitespace on start of line */
|
||||||
if(p >= buf + 64-1){
|
if(p >= buf + 64-1){
|
||||||
if(!f){
|
if(f == nil){
|
||||||
putc('\b');
|
putc('\b');
|
||||||
putc(' ');
|
putc(' ');
|
||||||
putc('\b');
|
putc('\b');
|
||||||
|
@ -171,7 +176,7 @@ getconf(char *s, char *buf)
|
||||||
for(e = p+1; e < confend; e++)
|
for(e = p+1; e < confend; e++)
|
||||||
if(*e == '\n')
|
if(*e == '\n')
|
||||||
break;
|
break;
|
||||||
if(!memcmp(p, s, n)){
|
if(memcmp(p, s, n) == 0){
|
||||||
p += n;
|
p += n;
|
||||||
n = e - p;
|
n = e - p;
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
|
@ -179,7 +184,7 @@ getconf(char *s, char *buf)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -194,7 +199,7 @@ delconf(char *s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!memcmp(p, s, strlen(s))){
|
if(memcmp(p, s, strlen(s)) == 0){
|
||||||
memmove(p, e, confend - e);
|
memmove(p, e, confend - e);
|
||||||
confend -= e - p;
|
confend -= e - p;
|
||||||
*confend = 0;
|
*confend = 0;
|
||||||
|
@ -225,45 +230,37 @@ Clear:
|
||||||
inblock = 0;
|
inblock = 0;
|
||||||
Loop:
|
Loop:
|
||||||
while(readline(f, line) > 0){
|
while(readline(f, line) > 0){
|
||||||
if(*line == 0 || strchr("#;=", *line))
|
if(*line == 0 || strchr("#;=", *line) != nil)
|
||||||
continue;
|
continue;
|
||||||
if(*line == '['){
|
if(*line == '['){
|
||||||
inblock = memcmp("[common]", line, 8);
|
inblock = memcmp("[common]", line, 8) != 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!memcmp("boot", line, 5)){
|
if(memcmp("boot", line, 5) == 0){
|
||||||
nowait=1;
|
nowait=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!memcmp("wait", line, 5)){
|
if(memcmp("wait", line, 5) == 0){
|
||||||
nowait=0;
|
nowait=0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!memcmp("show", line, 5)){
|
if(memcmp("show", line, 5) == 0){
|
||||||
for(p = BOOTARGS; p < confend; p++){
|
print(BOOTARGS);
|
||||||
if(*p == '\n')
|
|
||||||
print(crnl);
|
|
||||||
else
|
|
||||||
putc(*p);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(!memcmp("clear", line, 5)){
|
if(memcmp("clear", line, 5) == 0){
|
||||||
if(line[5] == 0){
|
if(line[5] == '\0'){
|
||||||
print("ok");
|
print("ok\n");
|
||||||
print(crnl);
|
|
||||||
goto Clear;
|
goto Clear;
|
||||||
} else if(line[5] == ' ' && delconf(line+6)){
|
} else if(line[5] == ' ' && delconf(line+6))
|
||||||
print("ok");
|
print("ok\n");
|
||||||
print(crnl);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(inblock || (p = strchr(line, '=')) == nil)
|
if(inblock != 0 || (p = strchr(line, '=')) == nil)
|
||||||
continue;
|
continue;
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
delconf(line);
|
delconf(line);
|
||||||
if(!memcmp("apm", line, 3)){
|
if(memcmp("apm", line, 3) == 0){
|
||||||
apmconf('0' - line[3]);
|
apmconf('0' - line[3]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -272,28 +269,25 @@ Loop:
|
||||||
memmove(confend, line, n = strlen(line)); confend += n;
|
memmove(confend, line, n = strlen(line)); confend += n;
|
||||||
*confend++ = '=';
|
*confend++ = '=';
|
||||||
memmove(confend, p, n = strlen(p)); confend += n;
|
memmove(confend, p, n = strlen(p)); confend += n;
|
||||||
*confend = 0;
|
|
||||||
|
|
||||||
print(s); print(crnl);
|
|
||||||
|
|
||||||
*confend++ = '\n';
|
*confend++ = '\n';
|
||||||
*confend = 0;
|
*confend = 0;
|
||||||
|
print(s);
|
||||||
}
|
}
|
||||||
kern = getconf("bootfile=", path);
|
kern = getconf("bootfile=", path);
|
||||||
|
|
||||||
if(f){
|
if(f != nil){
|
||||||
close(f);
|
close(f);
|
||||||
f = 0;
|
f = nil;
|
||||||
|
|
||||||
if(kern && (nowait==0 || timeout(1000)))
|
if(kern != nil && (nowait==0 || timeout(1000)))
|
||||||
goto Loop;
|
goto Loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!kern){
|
if(kern == nil){
|
||||||
print("no bootfile\r\n");
|
print("no bootfile\n");
|
||||||
goto Loop;
|
goto Loop;
|
||||||
}
|
}
|
||||||
while(p = strchr(kern, '!'))
|
while((p = strchr(kern, '!')) != nil)
|
||||||
kern = p+1;
|
kern = p+1;
|
||||||
|
|
||||||
return kern;
|
return kern;
|
||||||
|
@ -333,7 +327,7 @@ apmconf(int id)
|
||||||
memset(a, 0, 20);
|
memset(a, 0, 20);
|
||||||
|
|
||||||
apm(id);
|
apm(id);
|
||||||
if(memcmp(a, "APM", 4))
|
if(memcmp(a, "APM", 4) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s = confend;
|
s = confend;
|
||||||
|
@ -346,10 +340,10 @@ apmconf(int id)
|
||||||
addconfx(" di=", 4, *((ushort*)(a+10)));
|
addconfx(" di=", 4, *((ushort*)(a+10)));
|
||||||
addconfx(" esi=", 8, *((ulong*)(a+16)));
|
addconfx(" esi=", 8, *((ulong*)(a+16)));
|
||||||
|
|
||||||
print(s); print(crnl);
|
|
||||||
|
|
||||||
*confend++ = '\n';
|
*confend++ = '\n';
|
||||||
*confend = 0;
|
*confend = 0;
|
||||||
|
|
||||||
|
print(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -392,11 +386,10 @@ e820conf(void)
|
||||||
if(confend == s)
|
if(confend == s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
*confend = 0;
|
|
||||||
print(s); print(crnl);
|
|
||||||
|
|
||||||
*confend++ = '\n';
|
*confend++ = '\n';
|
||||||
*confend = 0;
|
*confend = 0;
|
||||||
|
|
||||||
|
print(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ulong
|
static ulong
|
||||||
|
@ -414,7 +407,7 @@ bootkern(void *f)
|
||||||
Exec ex;
|
Exec ex;
|
||||||
|
|
||||||
while(a20() < 0)
|
while(a20() < 0)
|
||||||
print("a20 enable failed\r\n");
|
print("a20 enable failed\n");
|
||||||
|
|
||||||
if(readn(f, &ex, sizeof(ex)) != sizeof(ex))
|
if(readn(f, &ex, sizeof(ex)) != sizeof(ex))
|
||||||
return "bad header";
|
return "bad header";
|
||||||
|
@ -448,8 +441,7 @@ bootkern(void *f)
|
||||||
close(f);
|
close(f);
|
||||||
unload();
|
unload();
|
||||||
|
|
||||||
print("boot");
|
print("boot\n");
|
||||||
print(crnl);
|
|
||||||
|
|
||||||
jump(e);
|
jump(e);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue