Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1323 → Rev 1324

/uspace/trunk/pci/libpci/i386-ports.c
3,7 → 3,7
*
* Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/pci.h
3,7 → 3,7
*
* Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/access.c
3,7 → 3,7
*
* Copyright (c) 1997--2003 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/internal.h
3,7 → 3,7
*
* Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/names.c
3,7 → 3,7
*
* Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
175,8 → 175,7
 
if (!nest) { /* Top-level entries */
if (p[0] == 'C' && p[1] == ' ') { /* Class block */
if ((id1 = id_hex(p + 2, 2)) < 0
|| !id_white_p(p[4]))
if ((id1 = id_hex(p + 2, 2)) < 0 || !id_white_p(p[4]))
return parse_error;
cat = ID_CLASS;
p += 5;
192,8 → 191,7
continue;
} else { /* Vendor ID */
 
if ((id1 = id_hex(p, 4)) < 0
|| !id_white_p(p[4]))
if ((id1 = id_hex(p, 4)) < 0 || !id_white_p(p[4]))
return parse_error;
cat = ID_VENDOR;
p += 5;
206,8 → 204,7
case ID_VENDOR:
case ID_DEVICE:
case ID_SUBSYSTEM:
if ((id2 = id_hex(p, 4)) < 0
|| !id_white_p(p[4]))
if ((id2 = id_hex(p, 4)) < 0 || !id_white_p(p[4]))
return parse_error;
p += 5;
cat = ID_DEVICE;
214,8 → 211,7
id3 = id4 = 0;
break;
case ID_GEN_SUBSYSTEM:
if ((id2 = id_hex(p, 4)) < 0
|| !id_white_p(p[4]))
if ((id2 = id_hex(p, 4)) < 0 || !id_white_p(p[4]))
return parse_error;
p += 5;
id3 = id4 = 0;
223,8 → 219,7
case ID_CLASS:
case ID_SUBCLASS:
case ID_PROGIF:
if ((id2 = id_hex(p, 2)) < 0
|| !id_white_p(p[2]))
if ((id2 = id_hex(p, 2)) < 0 || !id_white_p(p[2]))
return parse_error;
p += 3;
cat = ID_SUBCLASS;
236,10 → 231,8
switch (cat) {
case ID_DEVICE:
case ID_SUBSYSTEM:
if ((id3 = id_hex(p, 4)) < 0
|| !id_white_p(p[4])
|| (id4 = id_hex(p + 5, 4)) < 0
|| !id_white_p(p[9]))
if ((id3 = id_hex(p, 4)) < 0 || !id_white_p(p[4])
|| (id4 = id_hex(p + 5, 4)) < 0 || !id_white_p(p[9]))
return parse_error;
p += 10;
cat = ID_SUBSYSTEM;
247,8 → 240,7
case ID_CLASS:
case ID_SUBCLASS:
case ID_PROGIF:
if ((id3 = id_hex(p, 2)) < 0
|| !id_white_p(p[2]))
if ((id3 = id_hex(p, 2)) < 0 || !id_white_p(p[2]))
return parse_error;
p += 3;
cat = ID_PROGIF;
341,8 → 333,7
else if (v = id_lookup(a, ID_VENDOR, iv, 0, 0, 0))
return (char *) v->name;
else
res =
snprintf(buf, size, "Unknown vendor %04x", iv);
res = snprintf(buf, size, "Unknown vendor %04x", iv);
break;
case PCI_LOOKUP_DEVICE:
iv = va_arg(args, int);
352,8 → 343,7
else if (d = id_lookup(a, ID_DEVICE, iv, id, 0, 0))
return (char *) d->name;
else if (synth)
res =
snprintf(buf, size, "Unknown device %04x", id);
res = snprintf(buf, size, "Unknown device %04x", id);
else
return NULL;
break;
366,21 → 356,14
v = id_lookup(a, ID_VENDOR, iv, 0, 0, 0);
d = id_lookup(a, ID_DEVICE, iv, id, 0, 0);
if (v && d)
res =
snprintf(buf, size, "%s %s", v->name,
res = snprintf(buf, size, "%s %s", v->name,
d->name);
else if (!synth)
return NULL;
else if (!v)
res =
snprintf(buf, size,
"Unknown device %04x:%04x",
iv, id);
res = snprintf(buf, size, "Unknown device %04x:%04x", iv, id);
else /* !d */
res =
snprintf(buf, size,
"%s Unknown device %04x",
v->name, id);
res = snprintf(buf, size, "%s Unknown device %04x", v->name, id);
}
break;
case PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR:
390,9 → 373,7
else if (v = id_lookup(a, ID_VENDOR, isv, 0, 0, 0))
return (char *) v->name;
else if (synth)
res =
snprintf(buf, size, "Unknown vendor %04x",
isv);
res = snprintf(buf, size, "Unknown vendor %04x", isv);
else
return NULL;
break;
406,9 → 387,7
else if (d = id_lookup_subsys(a, iv, id, isv, isd))
return (char *) d->name;
else if (synth)
res =
snprintf(buf, size, "Unknown device %04x",
isd);
res = snprintf(buf, size, "Unknown device %04x", isd);
else
return NULL;
break;
423,21 → 402,13
v = id_lookup(a, ID_VENDOR, isv, 0, 0, 0);
d = id_lookup_subsys(a, iv, id, isv, isd);
if (v && d)
res =
snprintf(buf, size, "%s %s", v->name,
d->name);
res = snprintf(buf, size, "%s %s", v->name, d->name);
else if (!synth)
return NULL;
else if (!v)
res =
snprintf(buf, size,
"Unknown device %04x:%04x",
isv, isd);
res = snprintf(buf, size, "Unknown device %04x:%04x", isv, isd);
else /* !d */
res =
snprintf(buf, size,
"%s Unknown device %04x",
v->name, isd);
res = snprintf(buf, size, "%s Unknown device %04x", v->name, isd);
}
break;
case PCI_LOOKUP_CLASS:
444,14 → 415,10
icls = va_arg(args, int);
if (num)
res = snprintf(buf, size, "%04x", icls);
else if (cls =
id_lookup(a, ID_SUBCLASS, icls >> 8, icls & 0xff,
0, 0))
else if (cls = id_lookup(a, ID_SUBCLASS, icls >> 8, icls & 0xff, 0, 0))
return (char *) cls->name;
else if (cls = id_lookup(a, ID_CLASS, icls, 0, 0, 0))
res =
snprintf(buf, size, "%s [%04x]", cls->name,
icls);
res = snprintf(buf, size, "%s [%04x]", cls->name, icls);
else if (synth)
res = snprintf(buf, size, "Class %04x", icls);
else
462,9 → 429,7
ipif = va_arg(args, int);
if (num)
res = snprintf(buf, size, "%02x", ipif);
else if (pif =
id_lookup(a, ID_PROGIF, icls >> 8, icls & 0xff,
ipif, 0))
else if (pif = id_lookup(a, ID_PROGIF, icls >> 8, icls & 0xff, ipif, 0))
return (char *) pif->name;
else if (icls == 0x0101 && !(ipif & 0x70)) {
/* IDE controllers have complex prog-if semantics */
/uspace/trunk/pci/libpci/types.h
3,7 → 3,7
*
* Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/generic.c
3,7 → 3,7
*
* Copyright (c) 1997--2000 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
106,49 → 106,31
}
if (cnt) {
for (i = 0; i < cnt; i++) {
u32 x =
pci_read_long(d,
PCI_BASE_ADDRESS_0 +
i * 4);
u32 x = pci_read_long(d, PCI_BASE_ADDRESS_0 + i * 4);
if (!x || x == (u32) ~ 0)
continue;
if ((x & PCI_BASE_ADDRESS_SPACE) ==
PCI_BASE_ADDRESS_SPACE_IO)
if ((x & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO)
d->base_addr[i] = x;
else {
if ((x &
PCI_BASE_ADDRESS_MEM_TYPE_MASK)
!=
PCI_BASE_ADDRESS_MEM_TYPE_64)
if ((x & PCI_BASE_ADDRESS_MEM_TYPE_MASK) != PCI_BASE_ADDRESS_MEM_TYPE_64)
d->base_addr[i] = x;
else if (i >= cnt - 1)
a->warning
("%04x:%02x:%02x.%d: Invalid 64-bit address seen for BAR %d.",
a->warning("%04x:%02x:%02x.%d: Invalid 64-bit address seen for BAR %d.",
d->domain, d->bus,
d->dev, d->func, i);
else {
u32 y =
pci_read_long(d,
PCI_BASE_ADDRESS_0
+
(++i) *
4);
u32 y = pci_read_long(d, PCI_BASE_ADDRESS_0 + (++i) * 4);
#ifdef PCI_HAVE_64BIT_ADDRESS
d->base_addr[i - 1] =
x | (((pciaddr_t) y) <<
32);
d->base_addr[i - 1] = x | (((pciaddr_t) y) << 32);
#else
if (y)
a->warning
("%04x:%02x:%02x.%d 64-bit device address ignored.",
a->warning("%04x:%02x:%02x.%d 64-bit device address ignored.",
d->domain,
d->bus,
d->dev,
d->func);
else
d->base_addr[i -
1] =
x;
d->base_addr[i - 1] = x;
#endif
}
}
215,12 → 197,10
 
int pci_generic_block_read(struct pci_dev *d, int pos, byte * buf, int len)
{
return pci_generic_block_op(d, pos, buf, len,
d->access->methods->read);
return pci_generic_block_op(d, pos, buf, len, d->access->methods->read);
}
 
int pci_generic_block_write(struct pci_dev *d, int pos, byte * buf, int len)
{
return pci_generic_block_op(d, pos, buf, len,
d->access->methods->write);
return pci_generic_block_op(d, pos, buf, len, d->access->methods->write);
}
/uspace/trunk/pci/libpci/sysdep.h
3,7 → 3,7
*
* Copyright (c) 1997--2004 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
/uspace/trunk/pci/libpci/header.h
3,7 → 3,7
*
* Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
*
* Modified and ported to HelenOS by Jakub Jermar.
* May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/