Sun Jan 23 01:32:08 2011 UTC ()
- add "ll" modifier to printf.
- be more conscious about int type propagation.
- add missing version and newvers.sh


(nisimura)
diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/dsk.c
diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/globals.h
diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/printf.c
diff -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/newvers.sh
diff -r0 -r1.1 src/sys/arch/sandpoint/stand/altboot/version

cvs diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/dsk.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/altboot/dsk.c 2011/01/23 01:05:30 1.1
+++ src/sys/arch/sandpoint/stand/altboot/dsk.c 2011/01/23 01:32:08 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dsk.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */ 1/* $NetBSD: dsk.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -72,29 +72,29 @@ struct dskdv { @@ -72,29 +72,29 @@ struct dskdv {
72}; 72};
73 73
74static struct dskdv ldskdv[] = { 74static struct dskdv ldskdv[] = {
75 { "pciide", pciide_match, pciide_init, }, 75 { "pciide", pciide_match, pciide_init, },
76 { "siisata", siisata_match, siisata_init, }, 76 { "siisata", siisata_match, siisata_init, },
77}; 77};
78static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]); 78static int ndskdv = sizeof(ldskdv)/sizeof(ldskdv[0]);
79 79
80static int probe_drive(struct dkdev_ata *, int); 80static int probe_drive(struct dkdev_ata *, int);
81static void drive_ident(struct disk *, char *); 81static void drive_ident(struct disk *, char *);
82static char *mkident(char *, int); 82static char *mkident(char *, int);
83static void set_xfermode(struct dkdev_ata *, int); 83static void set_xfermode(struct dkdev_ata *, int);
84static void decode_dlabel(struct disk *, char *); 84static void decode_dlabel(struct disk *, char *);
85static int lba_read(struct disk *, uint64_t, uint32_t, void *); 85static int lba_read(struct disk *, int64_t, int, void *);
86static void issue48(struct dvata_chan *, uint64_t, uint32_t); 86static void issue48(struct dvata_chan *, int64_t, int);
87static void issue28(struct dvata_chan *, uint64_t, uint32_t); 87static void issue28(struct dvata_chan *, int64_t, int);
88static struct disk *lookup_disk(int); 88static struct disk *lookup_disk(int);
89 89
90static struct disk ldisk[4]; 90static struct disk ldisk[4];
91 91
92int 92int
93dskdv_init(unsigned tag, void **cookie) 93dskdv_init(unsigned tag, void **cookie)
94{ 94{
95 struct dskdv *dv; 95 struct dskdv *dv;
96 int n; 96 int n;
97 97
98 for (n = 0; n < ndskdv; n++) { 98 for (n = 0; n < ndskdv; n++) {
99 dv = &ldskdv[n]; 99 dv = &ldskdv[n];
100 if ((*dv->match)(tag, NULL) > 0) 100 if ((*dv->match)(tag, NULL) > 0)
@@ -358,81 +358,80 @@ static void @@ -358,81 +358,80 @@ static void
358set_xfermode(struct dkdev_ata *l, int n) 358set_xfermode(struct dkdev_ata *l, int n)
359{ 359{
360 struct dvata_chan *chan = &l->chan[n]; 360 struct dvata_chan *chan = &l->chan[n];
361 361
362 CSR_WRITE_1(chan->cmd + _FEA, ATA_XFER); 362 CSR_WRITE_1(chan->cmd + _FEA, ATA_XFER);
363 CSR_WRITE_1(chan->cmd + _NSECT, XFER_PIO0); 363 CSR_WRITE_1(chan->cmd + _NSECT, XFER_PIO0);
364 CSR_WRITE_1(chan->cmd + _DEV, ATA_DEV_OBS); /* ??? */ 364 CSR_WRITE_1(chan->cmd + _DEV, ATA_DEV_OBS); /* ??? */
365 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_SETF); 365 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_SETF);
366 366
367 spinwait_unbusy(l, n, 1000, NULL); 367 spinwait_unbusy(l, n, 1000, NULL);
368} 368}
369 369
370static int 370static int
371lba_read(struct disk *d, uint64_t bno, uint32_t bcnt, void *buf) 371lba_read(struct disk *d, int64_t bno, int bcnt, void *buf)
372{ 372{
373 struct dkdev_ata *l; 373 struct dkdev_ata *l;
374 struct dvata_chan *chan; 374 struct dvata_chan *chan;
375 void (*issue)(struct dvata_chan *, uint64_t, uint32_t); 375 void (*issue)(struct dvata_chan *, int64_t, int);
376 int n, rdcnt, i, k; 376 int n, rdcnt, i, k;
377 uint16_t *p; 377 uint16_t *p;
378 const char *err; 378 const char *err;
379 int error; 379 int error;
380 380
381 l = d->dvops; 381 l = d->dvops;
382 n = d->unittag; 382 n = d->unittag;
383 p = (uint16_t *)buf; 383 p = (uint16_t *)buf;
384 chan = &l->chan[n]; 384 chan = &l->chan[n];
385 error = 0; 385 error = 0;
386 for ( ; bcnt > 0; bno += rdcnt, bcnt -= rdcnt) { 386 for ( ; bcnt > 0; bno += rdcnt, bcnt -= rdcnt) {
387 issue = (bno < (1ULL<<28)) ? issue28 : issue48; 387 issue = (bno < (1ULL<<28)) ? issue28 : issue48;
388 rdcnt = (bcnt > 255) ? 255 : bcnt; 388 rdcnt = (bcnt > 255) ? 255 : bcnt;
389 (*issue)(chan, bno, rdcnt); 389 (*issue)(chan, bno, rdcnt);
390 for (k = 0; k < rdcnt; k++) { 390 for (k = 0; k < rdcnt; k++) {
391 if (spinwait_unbusy(l, n, 1000, &err) == 0) { 391 if (spinwait_unbusy(l, n, 1000, &err) == 0) {
392 printf("%s blk %d %s\n", 392 printf("%s blk %lld %s\n", d->xname, bno, err);
393 d->xname, (int)bno, err); 
394 error = EIO; 393 error = EIO;
395 break; 394 break;
396 } 395 }
397 for (i = 0; i < 512; i += 2) { 396 for (i = 0; i < 512; i += 2) {
398 /* arrives in native order */ 397 /* arrives in native order */
399 *p++ = *(uint16_t *)(chan->cmd + _DAT); 398 *p++ = *(uint16_t *)(chan->cmd + _DAT);
400 } 399 }
401 /* clear irq if any */ 400 /* clear irq if any */
402 (void)CSR_READ_1(chan->cmd + _STS); 401 (void)CSR_READ_1(chan->cmd + _STS);
403 } 402 }
404 } 403 }
405 return error; 404 return error;
406} 405}
407 406
408static void 407static void
409issue48(struct dvata_chan *chan, uint64_t bno, uint32_t nblk) 408issue48(struct dvata_chan *chan, int64_t bno, int nblk)
410{ 409{
411 410
412 CSR_WRITE_1(chan->cmd + _NSECT, 0); /* always less than 256 */ 411 CSR_WRITE_1(chan->cmd + _NSECT, 0); /* always less than 256 */
413 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 24) & 0xff); 412 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 24) & 0xff);
414 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 32) & 0xff); 413 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 32) & 0xff);
415 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 40) & 0xff); 414 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 40) & 0xff);
416 CSR_WRITE_1(chan->cmd + _NSECT, nblk); 415 CSR_WRITE_1(chan->cmd + _NSECT, nblk);
417 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 0) & 0xff); 416 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 0) & 0xff);
418 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 8) & 0xff); 417 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 8) & 0xff);
419 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 16) & 0xff); 418 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 16) & 0xff);
420 CSR_WRITE_1(chan->cmd + _DEV, ATA_DEV_LBA); 419 CSR_WRITE_1(chan->cmd + _DEV, ATA_DEV_LBA);
421 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_READ_EXT); 420 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_READ_EXT);
422} 421}
423 422
424static void 423static void
425issue28(struct dvata_chan *chan, uint64_t bno, uint32_t nblk) 424issue28(struct dvata_chan *chan, int64_t bno, int nblk)
426{ 425{
427 426
428 CSR_WRITE_1(chan->cmd + _NSECT, nblk); 427 CSR_WRITE_1(chan->cmd + _NSECT, nblk);
429 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 0) & 0xff); 428 CSR_WRITE_1(chan->cmd + _LBAL, (bno >> 0) & 0xff);
430 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 8) & 0xff); 429 CSR_WRITE_1(chan->cmd + _LBAM, (bno >> 8) & 0xff);
431 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 16) & 0xff); 430 CSR_WRITE_1(chan->cmd + _LBAH, (bno >> 16) & 0xff);
432 CSR_WRITE_1(chan->cmd + _DEV, ((bno >> 24) & 0xf) | ATA_DEV_LBA); 431 CSR_WRITE_1(chan->cmd + _DEV, ((bno >> 24) & 0xf) | ATA_DEV_LBA);
433 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_READ); 432 CSR_WRITE_1(chan->cmd + _CMD, ATA_CMD_READ);
434} 433}
435 434
436static struct disk * 435static struct disk *
437lookup_disk(int unit) 436lookup_disk(int unit)
438{ 437{
@@ -501,30 +500,30 @@ dsk_close(struct open_file *f) @@ -501,30 +500,30 @@ dsk_close(struct open_file *f)
501 500
502 (*fs->close)(f); 501 (*fs->close)(f);
503 d->fsops = NULL; 502 d->fsops = NULL;
504 f->f_devdata = NULL; 503 f->f_devdata = NULL;
505 return 0; 504 return 0;
506} 505}
507 506
508int 507int
509dsk_strategy(void *devdata, int rw, daddr_t dblk, size_t size, 508dsk_strategy(void *devdata, int rw, daddr_t dblk, size_t size,
510 void *p, size_t *rsize) 509 void *p, size_t *rsize)
511{ 510{
512 struct disk *d = devdata; 511 struct disk *d = devdata;
513 struct disklabel *dlp; 512 struct disklabel *dlp;
514 uint64_t bno; 513 int64_t bno;
515 514
516#if 0 515#if 0
517printf("%s %d %d\n", d->xname, (int)dblk, size); 516printf("%s %lld %d\n", d->xname, dblk, size);
518#endif 517#endif
519 if (size == 0) 518 if (size == 0)
520 return 0; 519 return 0;
521 if (rw != F_READ) 520 if (rw != F_READ)
522 return EOPNOTSUPP; 521 return EOPNOTSUPP;
523 522
524 bno = dblk; 523 bno = dblk;
525 if ((dlp = d->dlabel) != NULL) 524 if ((dlp = d->dlabel) != NULL)
526 bno += dlp->d_partitions[d->part].p_offset; 525 bno += dlp->d_partitions[d->part].p_offset;
527 (*d->lba_read)(d, bno, size / 512, p); 526 (*d->lba_read)(d, bno, size / 512, p);
528 if (rsize != NULL) 527 if (rsize != NULL)
529 *rsize = size; 528 *rsize = size;
530 return 0; 529 return 0;

cvs diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/globals.h (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/altboot/globals.h 2011/01/23 01:05:30 1.1
+++ src/sys/arch/sandpoint/stand/altboot/globals.h 2011/01/23 01:32:08 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: globals.h,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */ 1/* $NetBSD: globals.h,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
2 2
3/* clock feed */ 3/* clock feed */
4#ifndef EXT_CLK_FREQ 4#ifndef EXT_CLK_FREQ
5#define EXT_CLK_FREQ 33333333 /* external clock (PCI clock) */ 5#define EXT_CLK_FREQ 33333333 /* external clock (PCI clock) */
6#endif 6#endif
7 7
8/* brd type */ 8/* brd type */
9extern int brdtype; 9extern int brdtype;
10#define BRD_SANDPOINTX2 2 10#define BRD_SANDPOINTX2 2
11#define BRD_SANDPOINTX3 3 11#define BRD_SANDPOINTX3 3
12#define BRD_ENCOREPP1 10 12#define BRD_ENCOREPP1 10
13#define BRD_KUROBOX 100 13#define BRD_KUROBOX 100
14#define BRD_QNAPTS101 101 14#define BRD_QNAPTS101 101
@@ -176,19 +176,19 @@ struct dkdev_ata { @@ -176,19 +176,19 @@ struct dkdev_ata {
176 char *iobuf; 176 char *iobuf;
177}; 177};
178 178
179struct disk { 179struct disk {
180 char xname[8]; 180 char xname[8];
181 void *dvops; 181 void *dvops;
182 unsigned unittag; 182 unsigned unittag;
183 uint16_t ident[128]; 183 uint16_t ident[128];
184 uint64_t nsect; 184 uint64_t nsect;
185 uint64_t first; 185 uint64_t first;
186 void *dlabel; 186 void *dlabel;
187 int part; 187 int part;
188 void *fsops; 188 void *fsops;
189 int (*lba_read)(struct disk *, uint64_t, uint32_t, void *); 189 int (*lba_read)(struct disk *, int64_t, int, void *);
190}; 190};
191 191
192int spinwait_unbusy(struct dkdev_ata *, int, int, const char **); 192int spinwait_unbusy(struct dkdev_ata *, int, int, const char **);
193int perform_atareset(struct dkdev_ata *, int); 193int perform_atareset(struct dkdev_ata *, int);
194int satapresense(struct dkdev_ata *, int); 194int satapresense(struct dkdev_ata *, int);

cvs diff -r1.1 -r1.2 src/sys/arch/sandpoint/stand/altboot/Attic/printf.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/altboot/Attic/printf.c 2011/01/23 01:05:30 1.1
+++ src/sys/arch/sandpoint/stand/altboot/Attic/printf.c 2011/01/23 01:32:08 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: printf.c,v 1.1 2011/01/23 01:05:30 nisimura Exp $ */ 1/* $NetBSD: printf.c,v 1.2 2011/01/23 01:32:08 nisimura Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 */ 30 */
31 31
32/* 32/*
33 * printf -- format and write output using 'func' to write characters 33 * printf -- format and write output using 'func' to write characters
34 */ 34 */
35 35
36#include <sys/types.h> 36#include <sys/types.h>
37#include <machine/stdarg.h> 37#include <machine/stdarg.h>
38#include <lib/libsa/stand.h> 38#include <lib/libsa/stand.h>
39 39
40#define MAXSTR 80 40#define MAXSTR 80
41 41
42static int _doprnt(void (*)(int), const char *, va_list); 42static int _doprnt(void (*)(int), const char *, va_list);
43static void pr_int(unsigned long, int, char *); 43static void mkdigit(unsigned long long, int, char *);
44static void sputchar(int); 44static void sputchar(int);
45 45
46static char *sbuf, *ebuf; 46static char *sbuf, *ebuf;
47 47
48void 48void
49printf(const char *fmt, ...) 49printf(const char *fmt, ...)
50{ 50{
51 va_list ap; 51 va_list ap;
52 52
53 va_start(ap, fmt); 53 va_start(ap, fmt);
54 _doprnt(putchar, fmt, ap); 54 _doprnt(putchar, fmt, ap);
55 va_end(ap); 55 va_end(ap);
56} 56}
@@ -79,42 +79,34 @@ int @@ -79,42 +79,34 @@ int
79snprintf(char *buf, size_t size, const char *fmt, ...) 79snprintf(char *buf, size_t size, const char *fmt, ...)
80{ 80{
81 va_list ap; 81 va_list ap;
82 82
83 sbuf = buf; 83 sbuf = buf;
84 ebuf = buf + size - 1; 84 ebuf = buf + size - 1;
85 va_start(ap, fmt); 85 va_start(ap, fmt);
86 _doprnt(sputchar, fmt, ap); 86 _doprnt(sputchar, fmt, ap);
87 *sbuf = '\0'; 87 *sbuf = '\0';
88 return (sbuf - buf); 88 return (sbuf - buf);
89} 89}
90 90
91static int 91static int
92_doprnt(func, fmt, ap) 92_doprnt(void (*func)(int), const char *fmt, va_list ap)
93 void (*func)(int); /* Function to put a character */ 
94 const char *fmt; /* Format string for pr_int/pr_float */ 
95 va_list ap; /* Arguments to pr_int/pr_float */ 
96{ 93{
97 int i; 94 int i, outcnt;
98 char *str; 95 char buf[23], *str; /* requires 23 digits in octal at most */
99 char string[20]; 96 int length, fmax, fmin, leading;
100 int length; 97 int leftjust, llflag;
101 int leftjust; 98 char fill, sign;
102 int longflag; 99 long long v;
103 int fmax, fmin; 
104 int leading; 
105 int outcnt; 
106 char fill; 
107 char sign; 
108 100
109 outcnt = 0; 101 outcnt = 0;
110 while ((i = *fmt++) != '\0') { 102 while ((i = *fmt++) != '\0') {
111 if (i != '%') { 103 if (i != '%') {
112 (*func)(i); 104 (*func)(i);
113 outcnt += 1; 105 outcnt += 1;
114 continue; 106 continue;
115 } 107 }
116 if (*fmt == '%') { 108 if (*fmt == '%') {
117 (*func)(*fmt++); 109 (*func)(*fmt++);
118 outcnt += 1; 110 outcnt += 1;
119 continue; 111 continue;
120 } 112 }
@@ -131,80 +123,98 @@ _doprnt(func, fmt, ap) @@ -131,80 +123,98 @@ _doprnt(func, fmt, ap)
131 } 123 }
132 if (*fmt != '.') 124 if (*fmt != '.')
133 fmax = 0; 125 fmax = 0;
134 else { 126 else {
135 fmt++; 127 fmt++;
136 if (*fmt == '*') 128 if (*fmt == '*')
137 fmax = va_arg(ap, int); 129 fmax = va_arg(ap, int);
138 else { 130 else {
139 fmax = 0; 131 fmax = 0;
140 while ('0' <= *fmt && *fmt <= '9') 132 while ('0' <= *fmt && *fmt <= '9')
141 fmax = fmax * 10 + *fmt++ - '0'; 133 fmax = fmax * 10 + *fmt++ - '0';
142 } 134 }
143 } 135 }
144 longflag = (*fmt == 'l'); 136 llflag = 0;
145 if (longflag) 137 if (*fmt == 'l' && *++fmt == 'l') {
146 fmt++; 138 llflag = 1;
 139 fmt += 1;
 140 }
147 if ((i = *fmt++) == '\0') { 141 if ((i = *fmt++) == '\0') {
148 (*func)('%'); 142 (*func)('%');
149 outcnt += 1; 143 outcnt += 1;
150 break; 144 break;
151 } 145 }
152 str = string; 146 str = buf;
153 sign = ' '; 147 sign = ' ';
154 switch (i) { 148 switch (i) {
155 case 'c': 149 case 'c':
156 str[0] = va_arg(ap, int); 150 str[0] = va_arg(ap, int);
157 str[1] = '\0'; 151 str[1] = '\0';
158 fmax = 0; 152 fmax = 0;
159 fill = ' '; 153 fill = ' ';
160 break; 154 break;
161 155
162 case 's': 156 case 's':
163 str = va_arg(ap, char *); 157 str = va_arg(ap, char *);
164 fill = ' '; 158 fill = ' ';
165 break; 159 break;
166 160
167 case 'd': 161 case 'd':
168 { 162 if (llflag)
169 long l = va_arg(ap, long); 163 v = va_arg(ap, long long);
170 if (l < 0) { sign = '-' ; l = -l; } 164 else
171 pr_int((unsigned long)l, 10, str); 165 v = va_arg(ap, int);
172 } 166 if (v < 0) {
 167 sign = '-' ; v = -v;
 168 }
 169 mkdigit((unsigned long long)v, 10, str);
173 break; 170 break;
174 171
175 case 'u': 172 case 'u':
176 pr_int(va_arg(ap, unsigned long), 10, str); 173 if (llflag)
 174 v = va_arg(ap, long long);
 175 else
 176 v = va_arg(ap, int);
 177 mkdigit((unsigned long long)v, 10, str);
177 break; 178 break;
178 179
179 case 'o': 180 case 'o':
180 pr_int(va_arg(ap, unsigned long), 8, str); 181 if (llflag)
 182 v = va_arg(ap, long long);
 183 else
 184 v = va_arg(ap, int);
 185 mkdigit((unsigned long long)v, 8, str);
181 fmax = 0; 186 fmax = 0;
182 break; 187 break;
183 188
184 case 'X': 189 case 'X':
185 case 'x': 190 case 'x':
186 pr_int(va_arg(ap, unsigned long), 16, str); 191 if (llflag)
 192 v = va_arg(ap, long long);
 193 else
 194 v = va_arg(ap, int);
 195 mkdigit((unsigned long long)v, 16, str);
187 fmax = 0; 196 fmax = 0;
188 break; 197 break;
189 198
190 case 'p': 199 case 'p':
191 pr_int(va_arg(ap, unsigned long), 16, str); 200 mkdigit(va_arg(ap, unsigned int), 16, str);
192 fill = '0'; 201 fill = '0';
193 fmin = 8; 202 fmin = 8;
194 fmax = 0; 203 fmax = 0;
195 (*func)('0'); (*func)('x'); 204 (*func)('0'); (*func)('x');
196 outcnt += 2; 205 outcnt += 2;
197 break; 206 break;
 207
198 default: 208 default:
199 (*func)(i); 209 (*func)(i);
200 break; 210 break;
201 } 211 }
202 for (i = 0; str[i] != '\0'; i++) 212 for (i = 0; str[i] != '\0'; i++)
203 ; 213 ;
204 length = i; 214 length = i;
205 if (fmin > MAXSTR || fmin < 0) 215 if (fmin > MAXSTR || fmin < 0)
206 fmin = 0; 216 fmin = 0;
207 if (fmax > MAXSTR || fmax < 0) 217 if (fmax > MAXSTR || fmax < 0)
208 fmax = 0; 218 fmax = 0;
209 leading = 0; 219 leading = 0;
210 if (fmax != 0 || fmin != 0) { 220 if (fmax != 0 || fmin != 0) {
@@ -222,39 +232,40 @@ _doprnt(func, fmt, ap) @@ -222,39 +232,40 @@ _doprnt(func, fmt, ap)
222 (*func)(sign); 232 (*func)(sign);
223 if (leftjust == 0) 233 if (leftjust == 0)
224 for (i = 0; i < leading; i++) (*func)(fill); 234 for (i = 0; i < leading; i++) (*func)(fill);
225 if (sign == '-' && fill == ' ') 235 if (sign == '-' && fill == ' ')
226 (*func)(sign); 236 (*func)(sign);
227 for (i = 0; i < length; i++) 237 for (i = 0; i < length; i++)
228 (*func)(str[i]); 238 (*func)(str[i]);
229 if (leftjust != 0) 239 if (leftjust != 0)
230 for (i = 0; i < leading; i++) (*func)(fill); 240 for (i = 0; i < leading; i++) (*func)(fill);
231 } 241 }
232 return outcnt; 242 return outcnt;
233} 243}
234 244
235static void pr_int(lval, base, s) 245
236 unsigned long lval; 246static void
237 int base; 247mkdigit(unsigned long long llval, int base, char *s)
238 char *s; 
239{ 248{
240 char ptmp[12]; /* unsigned long requires 11 digit in octal form */ 249 char ptmp[23], *t; /* requires 22 digit in octal at most */
241 int i; 250 int n;
242 char *t = ptmp; 
243 static const char hexdigit[] = "0123456789abcdef"; 251 static const char hexdigit[] = "0123456789abcdef";
244 252
245 i = 1; 253 n = 1;
 254 t = ptmp;
246 *t++ = '\0'; 255 *t++ = '\0';
247 do { 256 do {
248 *t++ = hexdigit[lval % base]; 257 int d = (int)llval % base;
249 } while ((lval /= base) != 0 && ++i < sizeof(ptmp)); 258 *t++ = hexdigit[d];
 259 llval /= base;
 260 } while (llval != 0 && ++n < sizeof(ptmp));
250 while ((*s++ = *--t) != '\0') 261 while ((*s++ = *--t) != '\0')
251 ; 262 /* copy reserved digits */ ;
252} 263}
253 264
254static void 265static void
255sputchar(int c) 266sputchar(int c)
256{ 267{
257 268
258 if (sbuf < ebuf) 269 if (sbuf < ebuf)
259 *sbuf++ = c; 270 *sbuf++ = c;
260} 271}

File Added: src/sys/arch/sandpoint/stand/altboot/Attic/newvers.sh
#
# Usage: newvers.sh <historyrecord>
#
while read vers comment
do
	version=$vers
done < $1
developer=${USER:-"releng"}
[ -f /bin/hostname ] && buildhost=@`/bin/hostname`
date=`date`

cat <<EoF >vers.c
const char bootprog_rev[] = "$version";
const char bootprog_date[] = "$date";
const char bootprog_maker[] = "$developer$buildhost";
EoF

File Added: src/sys/arch/sandpoint/stand/altboot/version
1.0	initial version
1.1	PCI autoconf for multiple NIC device drivers
1.2	Synology-DS support, Marvell-Yukon driver, fixed aligned alloc
1.3	allow to have boot options, brdsetup.c cleanup to make brdtype
	maintainance more confortable
1.4	load kernels from local disk
1.5	altboot is the new name as this is capable of handling net & dsk.