{
cmd = PCI_CMD(bus, dev, devfn, PCI_VENDORID);
v = pci_read_config_word(cmd);
- //v = pci_read_config_long(cmd);
if(v == 0xFFFF)
continue;
-#if 0
- printk("dev %d ", dev);
- unsigned int i;
- for(i=0; i<16; ++i)
- {
- cmd = PCI_CMD(bus, dev, devfn, i*4);
- printk("%08x ", pci_read_config_long(cmd));
- }
-
- printk("\n");
-#endif
-
pci_device_t *pci = kmalloc(sizeof(pci_device_t), 0);
if(0 == pci)
{
// ========================================================================
#include "string.h"
-char *itoa(char *s, int n);
-char *itox(char *s, unsigned int n);
+char *itoa(char *s, int n);
+char *itou(char *s, unsigned int n);
+char *itox(char *s, unsigned int n);
enum {
ALIGN_RIGHT,
break;
case 'd':
itoa(tmp, *((int*)args));
- p += write_buf(p, tmp, char_fill, char_cnt, align);
+ p += write_buf(p, tmp, char_fill, char_cnt, align);
break;
case 's':
- p += write_buf(p, (const char *)*((unsigned int *) args), char_fill, char_cnt, align);
+ p += write_buf(p, (const char *)*((unsigned int *) args), char_fill, char_cnt, align);
+ break;
+ case 'u':
+ itou(tmp, *((unsigned int*)args));
+ p += write_buf(p, tmp, char_fill, char_cnt, align);
break;
case 'x':
itox(tmp, *((unsigned int *) args));
- p += write_buf(p, tmp, char_fill, char_cnt, align);
+ p += write_buf(p, tmp, char_fill, char_cnt, align);
break;
default:
break;
*p = 0;
}
+void swap_char(char *a, char *b)
+{
+ char c;
+ c = *a;
+ *a = *b;
+ *b = c;
+}
+
char *itoa(char *s, int n)
{
- int i;
- char tmp[64];
+ int i = 0;
+ char *p = 0;
+
if( n & 0x80000000 )
{
- n = ~n + 1;
- *s++ = '-';
+ n = ~n + 1;
+ *s++ = '-';
}
- i=0;
+
+ p = s;
+
do
{
- tmp[i++] = (n % 10) + '0';
- n /= 10;
+ *p++ = (n % 10) + '0';
+ n /= 10;
}while(n);
- while(i) *s++=tmp[--i];
- *s = 0;
+
+ *p-- = 0;
+
+ while(s < p)
+ {
+ swap_char(s, p);
+ s++;
+ p--;
+ }
+}
+
+
+char *itou(char *s, unsigned int n)
+{
+ char c;
+ char *p = s;
+
+ do
+ {
+ *p++ = (n % 10) + '0';
+ n /= 10;
+ }while(n);
+
+ *p-- = 0;
+
+ while(s < p)
+ {
+ swap_char(s, p);
+ s++;
+ p--;
+ }
}
char *itox(char *s, unsigned int n)
{
char *p = s;
- char ch,i,flag = 0;
-
- //*p++ = '0'; *p++ = 'x';
+ char ch;
+ int i;
if(n==0){*p++='0';*p=0;return s;}
+
for(i=28; i>=0; i-=4)
{
- ch = (n>>i) & 0x0F;
- if(ch >= 0) ch += '0';
- if(ch > '9') ch += 7;
- if(ch != '0') flag = 1;
- if(ch != '0' || flag == 1)
- *p++ = ch;
+ ch = (n>>i) & 0x0F;
+
+ if(ch>=0 && ch<=9)
+ {
+ ch += '0';
+ }
+ else
+ {
+ ch -= 10;
+ ch += 'A';
+ }
+
+ *p++ = ch;
}
+
*p = 0;
+
return s;
}