⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
字号:
/* -*-C-*- * * $Revision: 1.2 $ *   $Author: mechavar $ *     $Date: 2000/05/01 19:37:08 $ * * Copyright (c) 2000 ARM, INC. * All Rights Reserved. * *   Project: BootStrap Loader * *    */#include "uhal.h"#include <stdarg.h>#include <string.h>#include <ctype.h>#include "lib.h"#include "bsl_platform.h"#include "errors.h"#include "swis.h"#include "gdata.h"CallBack read_args_hex(char *tail, int argc, unsigned *argv){    unsigned tmp;    int i;    for (i = 0; i < argc; i++) {	if (!*tail) return ReportError(EINVAL, "Too few arguments");	tail = readhex(tail, &tmp);        if (*tail && *tail != ' ')            return ReportError(EINVAL, "Invalid characters in hex constant %s", tail);        argv[i] = tmp;        while (*tail == ' ') tail++;    }    return ReportOK();}int cistreq(char *s, char *t, int term){    for ( ; ((*s | 0x20) == (*t | 0x20)) || (*s <= term && *t <= term); s++, t++)        if (*s <= term)            return 1;    return 0;}int strlen_t(char *s, int term){    char *t = s;    while (*t <= term) t++;    return t-s;}char *nextword(char *word){    while (*word > ' ') word++;    while (*word == ' ') word++;    return word;}/* Compensate for trouble initializing c library support functions */char *readhex(char *word, unsigned *res){    unsigned c;    unsigned n;    n = 0;    do    {       c = (*word);       if ( (c<='f') && (c>='a') )       {	  c -= 'a' - 'A';       }       c -= '0';       if ( c > 9 )       {	  if ( c < 'A'-'0' )	  {	     break;	  }	  if ( c > 'F'-'0' )	  {	     break;	  }	  c -= 'A'- ('9' + 1);       }       n = n * 16 + c;       word++;    } while ( *word > 0);    *res = n;    return word;}char *lookupword(char *word, char *table){    while (*table > ' ' && *table <= '~') {	if (cistreq(word, table, ' ')) return table;	table += strlen(table) + 1;    }    return 0;}char *env_lookup(char *name){    return lookupword(name, (char *)ENV_BASE);}const char digits[] = "0123456789abcdef";void write_hex(unsigned w, void (*putc)(int)){    int i;     for (i = 0; i < 8; i++) {        putc(digits[w >> 28]);        w <<= 4;    }}void write_dec(unsigned w, void (*putc)(int)){    if (w >= 10) write_dec(w / 10, putc);    putc(w % 10 + '0');}void format_string(const char *fmt, void (*putc)(int), va_list args){    int c;    while (c = *fmt++) {        if (c != '%') {            putc(c);            continue;        }        switch (c = *fmt++) {            case 'd':		write_dec(va_arg(args, unsigned), putc);		break;            case 'x':		write_hex(va_arg(args, unsigned), putc);		break;            case 's': {	       int max_string = sizeof( command_line );		char *s = va_arg(args, char *);		while ( (c = *s++) && (max_string-- > 0)) putc(c);		break;	    }            case 0:		/* ARGH: Backup, Backup */		fmt--;		break;	    default:		putc(c);		break;        }    }}unsigned cksum(unsigned *base, unsigned *limit){    unsigned sum = 0;    while (base < limit) sum ^= *base++;    return sum;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -