vsprintf.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * linux/lib/vsprintf.c
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. */
  6. /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
  7. /*
  8. * Wirzenius wrote this portably, Torvalds fucked it up :-)
  9. */
  10. #include <stdarg.h>
  11. #include <linux/types.h>
  12. #include <linux/string.h>
  13. #include <linux/ctype.h>
  14. #include <common.h>
  15. #if !defined (CONFIG_PANIC_HANG)
  16. #include <command.h>
  17. /*cmd_boot.c*/
  18. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  19. #endif
  20. #ifdef CONFIG_SYS_64BIT_VSPRINTF
  21. #include <div64.h>
  22. # define NUM_TYPE long long
  23. #else
  24. # define NUM_TYPE long
  25. #define do_div(n, base) ({ \
  26. unsigned int __res; \
  27. __res = ((unsigned NUM_TYPE) n) % base; \
  28. n = ((unsigned NUM_TYPE) n) / base; \
  29. __res; \
  30. })
  31. #endif
  32. #define noinline __attribute__((noinline))
  33. const char hex_asc[] = "0123456789abcdef";
  34. #define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
  35. #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
  36. static inline char *pack_hex_byte(char *buf, u8 byte)
  37. {
  38. *buf++ = hex_asc_hi(byte);
  39. *buf++ = hex_asc_lo(byte);
  40. return buf;
  41. }
  42. unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
  43. {
  44. unsigned long result = 0,value;
  45. if (*cp == '0') {
  46. cp++;
  47. if ((*cp == 'x') && isxdigit(cp[1])) {
  48. base = 16;
  49. cp++;
  50. }
  51. if (!base) {
  52. base = 8;
  53. }
  54. }
  55. if (!base) {
  56. base = 10;
  57. }
  58. while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
  59. ? toupper(*cp) : *cp)-'A'+10) < base) {
  60. result = result*base + value;
  61. cp++;
  62. }
  63. if (endp)
  64. *endp = (char *)cp;
  65. return result;
  66. }
  67. long simple_strtol(const char *cp,char **endp,unsigned int base)
  68. {
  69. if(*cp=='-')
  70. return -simple_strtoul(cp+1,endp,base);
  71. return simple_strtoul(cp,endp,base);
  72. }
  73. int ustrtoul(const char *cp, char **endp, unsigned int base)
  74. {
  75. unsigned long result = simple_strtoul(cp, endp, base);
  76. switch (**endp) {
  77. case 'G' :
  78. result *= 1024;
  79. /* fall through */
  80. case 'M':
  81. result *= 1024;
  82. /* fall through */
  83. case 'K':
  84. case 'k':
  85. result *= 1024;
  86. if ((*endp)[1] == 'i') {
  87. if ((*endp)[2] == 'B')
  88. (*endp) += 3;
  89. else
  90. (*endp) += 2;
  91. }
  92. }
  93. return result;
  94. }
  95. #ifdef CONFIG_SYS_64BIT_STRTOUL
  96. unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int base)
  97. {
  98. unsigned long long result = 0, value;
  99. if (*cp == '0') {
  100. cp++;
  101. if ((*cp == 'x') && isxdigit (cp[1])) {
  102. base = 16;
  103. cp++;
  104. }
  105. if (!base) {
  106. base = 8;
  107. }
  108. }
  109. if (!base) {
  110. base = 10;
  111. }
  112. while (isxdigit (*cp) && (value = isdigit (*cp)
  113. ? *cp - '0'
  114. : (islower (*cp) ? toupper (*cp) : *cp) - 'A' + 10) < base) {
  115. result = result * base + value;
  116. cp++;
  117. }
  118. if (endp)
  119. *endp = (char *) cp;
  120. return result;
  121. }
  122. #endif /* CONFIG_SYS_64BIT_STRTOUL */
  123. /* we use this so that we can do without the ctype library */
  124. #define is_digit(c) ((c) >= '0' && (c) <= '9')
  125. static int skip_atoi(const char **s)
  126. {
  127. int i=0;
  128. while (is_digit(**s))
  129. i = i*10 + *((*s)++) - '0';
  130. return i;
  131. }
  132. /* Decimal conversion is by far the most typical, and is used
  133. * for /proc and /sys data. This directly impacts e.g. top performance
  134. * with many processes running. We optimize it for speed
  135. * using code from
  136. * http://www.cs.uiowa.edu/~jones/bcd/decimal.html
  137. * (with permission from the author, Douglas W. Jones). */
  138. /* Formats correctly any integer in [0,99999].
  139. * Outputs from one to five digits depending on input.
  140. * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
  141. static char* put_dec_trunc(char *buf, unsigned q)
  142. {
  143. unsigned d3, d2, d1, d0;
  144. d1 = (q>>4) & 0xf;
  145. d2 = (q>>8) & 0xf;
  146. d3 = (q>>12);
  147. d0 = 6*(d3 + d2 + d1) + (q & 0xf);
  148. q = (d0 * 0xcd) >> 11;
  149. d0 = d0 - 10*q;
  150. *buf++ = d0 + '0'; /* least significant digit */
  151. d1 = q + 9*d3 + 5*d2 + d1;
  152. if (d1 != 0) {
  153. q = (d1 * 0xcd) >> 11;
  154. d1 = d1 - 10*q;
  155. *buf++ = d1 + '0'; /* next digit */
  156. d2 = q + 2*d2;
  157. if ((d2 != 0) || (d3 != 0)) {
  158. q = (d2 * 0xd) >> 7;
  159. d2 = d2 - 10*q;
  160. *buf++ = d2 + '0'; /* next digit */
  161. d3 = q + 4*d3;
  162. if (d3 != 0) {
  163. q = (d3 * 0xcd) >> 11;
  164. d3 = d3 - 10*q;
  165. *buf++ = d3 + '0'; /* next digit */
  166. if (q != 0)
  167. *buf++ = q + '0'; /* most sign. digit */
  168. }
  169. }
  170. }
  171. return buf;
  172. }
  173. /* Same with if's removed. Always emits five digits */
  174. static char* put_dec_full(char *buf, unsigned q)
  175. {
  176. /* BTW, if q is in [0,9999], 8-bit ints will be enough, */
  177. /* but anyway, gcc produces better code with full-sized ints */
  178. unsigned d3, d2, d1, d0;
  179. d1 = (q>>4) & 0xf;
  180. d2 = (q>>8) & 0xf;
  181. d3 = (q>>12);
  182. /*
  183. * Possible ways to approx. divide by 10
  184. * gcc -O2 replaces multiply with shifts and adds
  185. * (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386)
  186. * (x * 0x67) >> 10: 1100111
  187. * (x * 0x34) >> 9: 110100 - same
  188. * (x * 0x1a) >> 8: 11010 - same
  189. * (x * 0x0d) >> 7: 1101 - same, shortest code (on i386)
  190. */
  191. d0 = 6*(d3 + d2 + d1) + (q & 0xf);
  192. q = (d0 * 0xcd) >> 11;
  193. d0 = d0 - 10*q;
  194. *buf++ = d0 + '0';
  195. d1 = q + 9*d3 + 5*d2 + d1;
  196. q = (d1 * 0xcd) >> 11;
  197. d1 = d1 - 10*q;
  198. *buf++ = d1 + '0';
  199. d2 = q + 2*d2;
  200. q = (d2 * 0xd) >> 7;
  201. d2 = d2 - 10*q;
  202. *buf++ = d2 + '0';
  203. d3 = q + 4*d3;
  204. q = (d3 * 0xcd) >> 11; /* - shorter code */
  205. /* q = (d3 * 0x67) >> 10; - would also work */
  206. d3 = d3 - 10*q;
  207. *buf++ = d3 + '0';
  208. *buf++ = q + '0';
  209. return buf;
  210. }
  211. /* No inlining helps gcc to use registers better */
  212. static noinline char* put_dec(char *buf, unsigned NUM_TYPE num)
  213. {
  214. while (1) {
  215. unsigned rem;
  216. if (num < 100000)
  217. return put_dec_trunc(buf, num);
  218. rem = do_div(num, 100000);
  219. buf = put_dec_full(buf, rem);
  220. }
  221. }
  222. #define ZEROPAD 1 /* pad with zero */
  223. #define SIGN 2 /* unsigned/signed long */
  224. #define PLUS 4 /* show plus */
  225. #define SPACE 8 /* space if plus */
  226. #define LEFT 16 /* left justified */
  227. #define SMALL 32 /* Must be 32 == 0x20 */
  228. #define SPECIAL 64 /* 0x */
  229. static char *number(char *buf, unsigned NUM_TYPE num, int base, int size, int precision, int type)
  230. {
  231. /* we are called with base 8, 10 or 16, only, thus don't need "G..." */
  232. static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
  233. char tmp[66];
  234. char sign;
  235. char locase;
  236. int need_pfx = ((type & SPECIAL) && base != 10);
  237. int i;
  238. /* locase = 0 or 0x20. ORing digits or letters with 'locase'
  239. * produces same digits or (maybe lowercased) letters */
  240. locase = (type & SMALL);
  241. if (type & LEFT)
  242. type &= ~ZEROPAD;
  243. sign = 0;
  244. if (type & SIGN) {
  245. if ((signed NUM_TYPE) num < 0) {
  246. sign = '-';
  247. num = - (signed NUM_TYPE) num;
  248. size--;
  249. } else if (type & PLUS) {
  250. sign = '+';
  251. size--;
  252. } else if (type & SPACE) {
  253. sign = ' ';
  254. size--;
  255. }
  256. }
  257. if (need_pfx) {
  258. size--;
  259. if (base == 16)
  260. size--;
  261. }
  262. /* generate full string in tmp[], in reverse order */
  263. i = 0;
  264. if (num == 0)
  265. tmp[i++] = '0';
  266. /* Generic code, for any base:
  267. else do {
  268. tmp[i++] = (digits[do_div(num,base)] | locase);
  269. } while (num != 0);
  270. */
  271. else if (base != 10) { /* 8 or 16 */
  272. int mask = base - 1;
  273. int shift = 3;
  274. if (base == 16) shift = 4;
  275. do {
  276. tmp[i++] = (digits[((unsigned char)num) & mask] | locase);
  277. num >>= shift;
  278. } while (num);
  279. } else { /* base 10 */
  280. i = put_dec(tmp, num) - tmp;
  281. }
  282. /* printing 100 using %2d gives "100", not "00" */
  283. if (i > precision)
  284. precision = i;
  285. /* leading space padding */
  286. size -= precision;
  287. if (!(type & (ZEROPAD+LEFT)))
  288. while(--size >= 0)
  289. *buf++ = ' ';
  290. /* sign */
  291. if (sign)
  292. *buf++ = sign;
  293. /* "0x" / "0" prefix */
  294. if (need_pfx) {
  295. *buf++ = '0';
  296. if (base == 16)
  297. *buf++ = ('X' | locase);
  298. }
  299. /* zero or space padding */
  300. if (!(type & LEFT)) {
  301. char c = (type & ZEROPAD) ? '0' : ' ';
  302. while (--size >= 0)
  303. *buf++ = c;
  304. }
  305. /* hmm even more zero padding? */
  306. while (i <= --precision)
  307. *buf++ = '0';
  308. /* actual digits of result */
  309. while (--i >= 0)
  310. *buf++ = tmp[i];
  311. /* trailing space padding */
  312. while (--size >= 0)
  313. *buf++ = ' ';
  314. return buf;
  315. }
  316. static char *string(char *buf, char *s, int field_width, int precision, int flags)
  317. {
  318. int len, i;
  319. if (s == 0)
  320. s = "<NULL>";
  321. len = strnlen(s, precision);
  322. if (!(flags & LEFT))
  323. while (len < field_width--)
  324. *buf++ = ' ';
  325. for (i = 0; i < len; ++i)
  326. *buf++ = *s++;
  327. while (len < field_width--)
  328. *buf++ = ' ';
  329. return buf;
  330. }
  331. #ifdef CONFIG_CMD_NET
  332. static char *mac_address_string(char *buf, u8 *addr, int field_width,
  333. int precision, int flags)
  334. {
  335. char mac_addr[6 * 3]; /* (6 * 2 hex digits), 5 colons and trailing zero */
  336. char *p = mac_addr;
  337. int i;
  338. for (i = 0; i < 6; i++) {
  339. p = pack_hex_byte(p, addr[i]);
  340. if (!(flags & SPECIAL) && i != 5)
  341. *p++ = ':';
  342. }
  343. *p = '\0';
  344. return string(buf, mac_addr, field_width, precision, flags & ~SPECIAL);
  345. }
  346. static char *ip6_addr_string(char *buf, u8 *addr, int field_width,
  347. int precision, int flags)
  348. {
  349. char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */
  350. char *p = ip6_addr;
  351. int i;
  352. for (i = 0; i < 8; i++) {
  353. p = pack_hex_byte(p, addr[2 * i]);
  354. p = pack_hex_byte(p, addr[2 * i + 1]);
  355. if (!(flags & SPECIAL) && i != 7)
  356. *p++ = ':';
  357. }
  358. *p = '\0';
  359. return string(buf, ip6_addr, field_width, precision, flags & ~SPECIAL);
  360. }
  361. static char *ip4_addr_string(char *buf, u8 *addr, int field_width,
  362. int precision, int flags)
  363. {
  364. char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
  365. char temp[3]; /* hold each IP quad in reverse order */
  366. char *p = ip4_addr;
  367. int i, digits;
  368. for (i = 0; i < 4; i++) {
  369. digits = put_dec_trunc(temp, addr[i]) - temp;
  370. /* reverse the digits in the quad */
  371. while (digits--)
  372. *p++ = temp[digits];
  373. if (i != 3)
  374. *p++ = '.';
  375. }
  376. *p = '\0';
  377. return string(buf, ip4_addr, field_width, precision, flags & ~SPECIAL);
  378. }
  379. #endif
  380. /*
  381. * Show a '%p' thing. A kernel extension is that the '%p' is followed
  382. * by an extra set of alphanumeric characters that are extended format
  383. * specifiers.
  384. *
  385. * Right now we handle:
  386. *
  387. * - 'M' For a 6-byte MAC address, it prints the address in the
  388. * usual colon-separated hex notation
  389. * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated
  390. * decimal for v4 and colon separated network-order 16 bit hex for v6)
  391. * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is
  392. * currently the same
  393. *
  394. * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
  395. * function pointers are really function descriptors, which contain a
  396. * pointer to the real address.
  397. */
  398. static char *pointer(const char *fmt, char *buf, void *ptr, int field_width, int precision, int flags)
  399. {
  400. if (!ptr)
  401. return string(buf, "(null)", field_width, precision, flags);
  402. #ifdef CONFIG_CMD_NET
  403. switch (*fmt) {
  404. case 'm':
  405. flags |= SPECIAL;
  406. /* Fallthrough */
  407. case 'M':
  408. return mac_address_string(buf, ptr, field_width, precision, flags);
  409. case 'i':
  410. flags |= SPECIAL;
  411. /* Fallthrough */
  412. case 'I':
  413. if (fmt[1] == '6')
  414. return ip6_addr_string(buf, ptr, field_width, precision, flags);
  415. if (fmt[1] == '4')
  416. return ip4_addr_string(buf, ptr, field_width, precision, flags);
  417. flags &= ~SPECIAL;
  418. break;
  419. }
  420. #endif
  421. flags |= SMALL;
  422. if (field_width == -1) {
  423. field_width = 2*sizeof(void *);
  424. flags |= ZEROPAD;
  425. }
  426. return number(buf, (unsigned long) ptr, 16, field_width, precision, flags);
  427. }
  428. /**
  429. * vsprintf - Format a string and place it in a buffer
  430. * @buf: The buffer to place the result into
  431. * @fmt: The format string to use
  432. * @args: Arguments for the format string
  433. *
  434. * This function follows C99 vsprintf, but has some extensions:
  435. * %pS output the name of a text symbol
  436. * %pF output the name of a function pointer
  437. * %pR output the address range in a struct resource
  438. *
  439. * The function returns the number of characters written
  440. * into @buf.
  441. *
  442. * Call this function if you are already dealing with a va_list.
  443. * You probably want sprintf() instead.
  444. */
  445. int vsprintf(char *buf, const char *fmt, va_list args)
  446. {
  447. unsigned NUM_TYPE num;
  448. int base;
  449. char *str;
  450. int flags; /* flags to number() */
  451. int field_width; /* width of output field */
  452. int precision; /* min. # of digits for integers; max
  453. number of chars for from string */
  454. int qualifier; /* 'h', 'l', or 'L' for integer fields */
  455. /* 'z' support added 23/7/1999 S.H. */
  456. /* 'z' changed to 'Z' --davidm 1/25/99 */
  457. /* 't' added for ptrdiff_t */
  458. str = buf;
  459. for (; *fmt ; ++fmt) {
  460. if (*fmt != '%') {
  461. *str++ = *fmt;
  462. continue;
  463. }
  464. /* process flags */
  465. flags = 0;
  466. repeat:
  467. ++fmt; /* this also skips first '%' */
  468. switch (*fmt) {
  469. case '-': flags |= LEFT; goto repeat;
  470. case '+': flags |= PLUS; goto repeat;
  471. case ' ': flags |= SPACE; goto repeat;
  472. case '#': flags |= SPECIAL; goto repeat;
  473. case '0': flags |= ZEROPAD; goto repeat;
  474. }
  475. /* get field width */
  476. field_width = -1;
  477. if (is_digit(*fmt))
  478. field_width = skip_atoi(&fmt);
  479. else if (*fmt == '*') {
  480. ++fmt;
  481. /* it's the next argument */
  482. field_width = va_arg(args, int);
  483. if (field_width < 0) {
  484. field_width = -field_width;
  485. flags |= LEFT;
  486. }
  487. }
  488. /* get the precision */
  489. precision = -1;
  490. if (*fmt == '.') {
  491. ++fmt;
  492. if (is_digit(*fmt))
  493. precision = skip_atoi(&fmt);
  494. else if (*fmt == '*') {
  495. ++fmt;
  496. /* it's the next argument */
  497. precision = va_arg(args, int);
  498. }
  499. if (precision < 0)
  500. precision = 0;
  501. }
  502. /* get the conversion qualifier */
  503. qualifier = -1;
  504. if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
  505. *fmt == 'Z' || *fmt == 'z' || *fmt == 't') {
  506. qualifier = *fmt;
  507. ++fmt;
  508. if (qualifier == 'l' && *fmt == 'l') {
  509. qualifier = 'L';
  510. ++fmt;
  511. }
  512. }
  513. /* default base */
  514. base = 10;
  515. switch (*fmt) {
  516. case 'c':
  517. if (!(flags & LEFT))
  518. while (--field_width > 0)
  519. *str++ = ' ';
  520. *str++ = (unsigned char) va_arg(args, int);
  521. while (--field_width > 0)
  522. *str++ = ' ';
  523. continue;
  524. case 's':
  525. str = string(str, va_arg(args, char *), field_width, precision, flags);
  526. continue;
  527. case 'p':
  528. str = pointer(fmt+1, str,
  529. va_arg(args, void *),
  530. field_width, precision, flags);
  531. /* Skip all alphanumeric pointer suffixes */
  532. while (isalnum(fmt[1]))
  533. fmt++;
  534. continue;
  535. case 'n':
  536. if (qualifier == 'l') {
  537. long * ip = va_arg(args, long *);
  538. *ip = (str - buf);
  539. } else {
  540. int * ip = va_arg(args, int *);
  541. *ip = (str - buf);
  542. }
  543. continue;
  544. case '%':
  545. *str++ = '%';
  546. continue;
  547. /* integer number formats - set up the flags and "break" */
  548. case 'o':
  549. base = 8;
  550. break;
  551. case 'x':
  552. flags |= SMALL;
  553. case 'X':
  554. base = 16;
  555. break;
  556. case 'd':
  557. case 'i':
  558. flags |= SIGN;
  559. case 'u':
  560. break;
  561. default:
  562. *str++ = '%';
  563. if (*fmt)
  564. *str++ = *fmt;
  565. else
  566. --fmt;
  567. continue;
  568. }
  569. #ifdef CONFIG_SYS_64BIT_VSPRINTF
  570. if (qualifier == 'L') /* "quad" for 64 bit variables */
  571. num = va_arg(args, unsigned long long);
  572. else
  573. #endif
  574. if (qualifier == 'l') {
  575. num = va_arg(args, unsigned long);
  576. if (flags & SIGN)
  577. num = (signed long) num;
  578. } else if (qualifier == 'Z' || qualifier == 'z') {
  579. num = va_arg(args, size_t);
  580. } else if (qualifier == 't') {
  581. num = va_arg(args, ptrdiff_t);
  582. } else if (qualifier == 'h') {
  583. num = (unsigned short) va_arg(args, int);
  584. if (flags & SIGN)
  585. num = (signed short) num;
  586. } else {
  587. num = va_arg(args, unsigned int);
  588. if (flags & SIGN)
  589. num = (signed int) num;
  590. }
  591. str = number(str, num, base, field_width, precision, flags);
  592. }
  593. *str = '\0';
  594. return str-buf;
  595. }
  596. /**
  597. * sprintf - Format a string and place it in a buffer
  598. * @buf: The buffer to place the result into
  599. * @fmt: The format string to use
  600. * @...: Arguments for the format string
  601. *
  602. * The function returns the number of characters written
  603. * into @buf.
  604. *
  605. * See the vsprintf() documentation for format string extensions over C99.
  606. */
  607. int sprintf(char * buf, const char *fmt, ...)
  608. {
  609. va_list args;
  610. int i;
  611. va_start(args, fmt);
  612. i=vsprintf(buf,fmt,args);
  613. va_end(args);
  614. return i;
  615. }
  616. void panic(const char *fmt, ...)
  617. {
  618. va_list args;
  619. va_start(args, fmt);
  620. vprintf(fmt, args);
  621. putc('\n');
  622. va_end(args);
  623. #if defined (CONFIG_PANIC_HANG)
  624. hang();
  625. #else
  626. udelay (100000); /* allow messages to go out */
  627. do_reset (NULL, 0, 0, NULL);
  628. #endif
  629. }