9boot: fix 9bootiso
rearrange sub.c for putc(), readn(), memcmp(), memmove(), strchr() and strlen() and uart to fit into the first 2K of the image.
This commit is contained in:
parent
c9c06dd8ba
commit
2fc31e9a70
3 changed files with 36 additions and 34 deletions
|
@ -1,5 +1,6 @@
|
||||||
/* handy strings in l.s */
|
/* handy strings in l.s */
|
||||||
extern char origin[];
|
extern char origin[];
|
||||||
|
extern char uart;
|
||||||
extern char hex[];
|
extern char hex[];
|
||||||
extern char bootname[];
|
extern char bootname[];
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,9 @@ TEXT bootname(SB), $0
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TEXT uart(SB), $0
|
||||||
|
BYTE $0xff
|
||||||
|
|
||||||
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';
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
|
||||||
int uart = -1;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
putc(int c)
|
putc(int c)
|
||||||
{
|
{
|
||||||
|
@ -24,25 +22,25 @@ print(char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
getc(void)
|
readn(void *f, void *data, int len)
|
||||||
{
|
{
|
||||||
int c;
|
uchar *p, *e;
|
||||||
|
|
||||||
c = kbdgetc();
|
putc(' ');
|
||||||
if(c == 0 && uart != -1)
|
p = data;
|
||||||
c = uartgetc(uart);
|
e = p + len;
|
||||||
return c & 0x7f;
|
while(p < e){
|
||||||
|
if(((ulong)p & 0xF000) == 0){
|
||||||
|
putc('\b');
|
||||||
|
putc(hex[((ulong)p>>16)&0xF]);
|
||||||
}
|
}
|
||||||
|
if((len = read(f, p, e - p)) <= 0)
|
||||||
void
|
break;
|
||||||
memset(void *dst, int v, int n)
|
p += len;
|
||||||
{
|
|
||||||
uchar *d = dst;
|
|
||||||
|
|
||||||
while(n > 0){
|
|
||||||
*d++ = v;
|
|
||||||
n--;
|
|
||||||
}
|
}
|
||||||
|
putc('\b');
|
||||||
|
|
||||||
|
return p - (uchar*)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -99,26 +97,26 @@ strchr(char *s, int c)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
readn(void *f, void *data, int len)
|
memset(void *dst, int v, int n)
|
||||||
{
|
{
|
||||||
uchar *p, *e;
|
uchar *d = dst;
|
||||||
|
|
||||||
putc(' ');
|
while(n > 0){
|
||||||
p = data;
|
*d++ = v;
|
||||||
e = p + len;
|
n--;
|
||||||
while(p < e){
|
|
||||||
if(((ulong)p & 0xF000) == 0){
|
|
||||||
putc('\b');
|
|
||||||
putc(hex[((ulong)p>>16)&0xF]);
|
|
||||||
}
|
}
|
||||||
if((len = read(f, p, e - p)) <= 0)
|
|
||||||
break;
|
|
||||||
p += len;
|
|
||||||
}
|
}
|
||||||
putc('\b');
|
|
||||||
|
|
||||||
return p - (uchar*)data;
|
int
|
||||||
|
getc(void)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
c = kbdgetc();
|
||||||
|
if(c == 0 && uart != -1)
|
||||||
|
c = uartgetc(uart);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue