M carrera/mem.h => carrera/mem.h +1 -0
@@ 166,6 166,7 @@
#define KSEG2 0xC0000000
#define KSEG3 0xE0000000
#define KSEGM 0xE0000000 /* mask to check which seg */
+#define CACHELINESZ 128
#define PIDXSHFT 12
#define PIDX (0x7<<PIDXSHFT)
M pc/devfloppy.c => pc/devfloppy.c +1 -1
@@ 1042,7 1042,7 @@ floppyformat(Drive *dp, char *params)
/*
* set the type
*/
- if(getfields(params, f, 3, ' ') > 1){
+ if(getfields(params, f, 3, " ") > 1){
for(t = floppytype; t < &floppytype[NTYPES]; t++)
if(strcmp(f[1], t->name)==0 && t->dt==dp->dt){
dp->t = t;
M pc/devhard.c => pc/devhard.c +5 -5
@@ 880,12 880,12 @@ hardreplinit(Drive *dp)
/*
* parse replacement table.
*/
- n = getfields(buf, line, Nrepl+1, '\n');
+ n = getfields(buf, line, Nrepl+1, "\n");
if(strncmp(line[0], REPLMAGIC, sizeof(REPLMAGIC)-1)){
dp->repl.p = 0;
} else {
for(dp->repl.nrepl = 0, i = 1; i < n; i++, dp->repl.nrepl++){
- if(getfields(line[i], field, 1, ' ') != 1)
+ if(getfields(line[i], field, 1, " ") != 1)
break;
dp->repl.blk[dp->repl.nrepl] = strtoul(field[0], 0, 0);
if(dp->repl.blk[dp->repl.nrepl] <= 0)
@@ 948,14 948,14 @@ hardpart(Drive *dp)
*/
hardxfer(dp, pp, Cread, 0, dp->bytes, buf);
buf[dp->bytes-1] = 0;
- n = getfields(buf, line, Npart+1, '\n');
+ n = getfields(buf, line, Npart+1, "\n");
if(n == 0 || strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1)){
dp->p[0].end--;
dp->p[1].start--;
dp->p[1].end--;
hardxfer(dp, pp, Cread, 0, dp->bytes, buf);
buf[dp->bytes-1] = 0;
- n = getfields(buf, line, Npart+1, '\n');
+ n = getfields(buf, line, Npart+1, "\n");
}
/*
@@ 964,7 964,7 @@ hardpart(Drive *dp)
if(n && strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) == 0){
for(i = 1; i < n; i++){
pp++;
- switch(getfields(line[i], field, 3, ' ')) {
+ switch(getfields(line[i], field, 3, " ")) {
case 2:
if(strcmp(field[0], "unit") == 0)
strncpy(dp->vol, field[1], NAMELEN);
M pc/devi82365.c => pc/devi82365.c +2 -2
@@ 151,7 151,7 @@ struct Slot
uchar busy;
/* cis info */
- uchar verstr[512]; /* version string */
+ char verstr[512]; /* version string */
uchar vpp1;
uchar vpp2;
uchar bit16;
@@ 1173,7 1173,7 @@ tvers1(Slot *pp, int ttype)
if(readc(pp, &minor) != 1)
return;
for(i = 0; i < sizeof(pp->verstr)-1; i++){
- if(readc(&c) != 1)
+ if(readc(pp, &c) != 1)
return;
if(c == 0)
c = '\n';
M pc/devvga.c => pc/devvga.c +1 -1
@@ 256,7 256,7 @@ vgactl(char *arg)
int i, x, y, z;
char *cp, *field[3];
- if(getfields(arg, field, 3, ' ') != 2)
+ if(getfields(arg, field, 3, " ") != 2)
error(Ebadarg);
if(strcmp(field[0], "hwgc") == 0){
M pc/kbd.c => pc/kbd.c +1 -1
@@ 543,7 543,7 @@ mousectl(char *arg)
int n, x;
char *field[3];
- n = getfields(arg, field, 3, ' ');
+ n = getfields(arg, field, 3, " ");
if(strncmp(field[0], "serial", 6) == 0){
switch(n){
case 1:
M pc/main.c => pc/main.c +1 -1
@@ 361,7 361,7 @@ confinit(void)
*/
cp = BOOTARGS; /* where b.com leaves its config */
cp[BOOTARGSLEN-1] = 0;
- n = getfields(cp, line, MAXCONF, '\n');
+ n = getfields(cp, line, MAXCONF, "\n");
for(j = 0; j < n; j++){
cp = strchr(line[j], '\r');
if(cp)
M port/devcons.c => port/devcons.c +6 -0
@@ 95,6 95,12 @@ putstrn(char *str, int n)
}
int
+snprint(char *s, int n, char *fmt, ...)
+{
+ return doprint(s, s+n, fmt, (&fmt+1)) - s;
+}
+
+int
sprint(char *s, char *fmt, ...)
{
return doprint(s, s+PRINTSIZE, fmt, (&fmt+1)) - s;
M port/devsd.c => port/devsd.c +2 -2
@@ 279,10 279,10 @@ sdrdpart(Disk *d)
/*
* parse partition table.
*/
- n = getfields(b, line, Npart+2, '\n');
+ n = getfields(b, line, Npart+2, "\n");
if(n > 0 && strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0) {
for(i = 1; i < n; i++) {
- switch(getfields(line[i], field, 3, ' ')) {
+ switch(getfields(line[i], field, 3, " ")) {
case 2:
if(strcmp(field[0], "unit") == 0)
strncpy(d->vol, field[1], NAMELEN);
M port/lib.h => port/lib.h +1 -0
@@ 60,6 60,7 @@ extern int numbconv(void*, Fconv*);
extern char *doprint(char*, char*, char*, void*);
extern int fmtinstall(int, int (*)(void*, Fconv*));
extern int sprint(char*, char*, ...);
+extern int snprint(char*, int, char*, ...);
extern int print(char*, ...);
/*
M port/portfns.h => port/portfns.h +1 -1
@@ 89,7 89,7 @@ void freepte(Segment*, Pte*);
void freesegs(int);
void freesession(Session*);
void getcolor(ulong, ulong*, ulong*, ulong*);
-int getfields(char*, char**, int, char);
+int getfields(char*, char**, int, char*);
void gotolabel(Label*);
void graphicsactive(int);
int haswaitq(void*);